security

package
v1.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2023 License: MIT Imports: 1 Imported by: 2

Documentation

Index

Constants

View Source
const ENABLE_SECURITY = true

noinspection GoUnusedConst,GoSnakeCaseUsage

Variables

Functions

This section is empty.

Types

type IAccessControlHandler

type IAccessControlHandler interface {
	AddOrUpdateAccessControl(key uint64, value uint64, editor Identity) error
	AccessControls() map[uint64]uint64
}

type ISecurityHandler

type ISecurityHandler interface {
	AccessControlHandler() IAccessControlHandler
	SetAccessControlHandler(IAccessControlHandler)
	Validate(phoneNumber string, password string) (string, error)
	Verify(token string, confirmationCode string) (string, uint64, error)
	RefreshTokenCache(identity Identity, token string) error
	Authenticate(token string, role Role, remoteAddress string, userAgent string) Identity
	SignOut(Identity) error
}

type Identity

type Identity interface {
	Id() int64
	Username() string
	PhoneNumber() string
	FirstName() string
	LastName() string
	Email() string
	Token() string
	SetToken(token string)
	MultiFactor() bool
	RemoteAddress() string
	SetRemoteAddress(string)
	UserAgent() string
	SetUserAgent(string)
	Hash() string
	Salt() string
	PublicKey() string
	PrivateKey() string
	Permission() uint64
	Restriction() uint32
	Role() Role
	IsInRole(role Role) bool
	IsRestricted() bool
	IsNotRestricted() bool
	Payload() Pointer
	Lock(uint64)
	Unlock(uint64)
	SetSystemCallHandler(func(Identity, []string) error)
	SystemCall(Identity, []string) error
}

type IdentityCache

type IdentityCache interface {
	Put(int64, Identity)
	Remove(int64)
	Get(int64) (Identity, bool)
	Size() int
	GetByToken(string) (Identity, bool)
	GetByUsername(string) (Identity, bool)
	GetByPhoneNumber(string) (Identity, bool)
	RefreshToken(Identity, string)
	ForEachValue(func(ISystemObject))
	Load(map[int64]ISystemObject)
	Clear()
	OnChanged(func())

	StoreAuthorizationInfo(string, string, string)
	RetrieveAuthorizationInfo(string) (string, string, error)
}

type Role

type Role = uint64
const (
	ANONYMOUS     Role = 0b0000_0000_0000_0000_0000_0000_0000_0000
	USER          Role = 0b0000_0000_0000_0000_0000_0000_0000_0001
	ADMINISTRATOR Role = 0b1111_1111_1111_1111_1111_1111_1111_1111
)

noinspection GoUnusedConst,GoSnakeCaseUsage

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL