Documentation ¶
Index ¶
- Constants
- func HashKey(key []byte) string
- type ACLRule
- type KeyStore
- func (store *KeyStore) CheckPermission(requestType int, channelName string, key []byte) bool
- func (store *KeyStore) CleanUp()
- func (store *KeyStore) GenerateKeyAndRegister(name string, rules []ACLRule, duration time.Duration) string
- func (store *KeyStore) GetExpireTime(key []byte) time.Time
- func (store *KeyStore) GetSessionKey(key []byte) *SessionKey
- func (store *KeyStore) LoadKeyStore(FileName string) error
- func (store *KeyStore) RegisterKey(Key []byte, property SessionKey) error
- func (store *KeyStore) Save(FileName string) error
- func (store *KeyStore) UpdateKey(Key []byte, property SessionKey)
- type SessionKey
Constants ¶
const ( // UndefinedACL indicates that the control rule is undefined. // If all matching rules are `undefined`, KeyStore will return a reject decision. UndefinedACL = iota // Allow indicates that this policy is allowed. Allow = iota // Deny indicates that this policy is denied. Deny = iota // InvokeAction indicates invoke type of requests. InvokeAction = iota // ListenAction indicates listen type of requests. ListenAction = iota )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ACLRule ¶
type ACLRule struct { // Controls the ability to listen to a channel. ListenControl int `json:"listen" default:"0"` // Controls the ability to invoke services on a channel. InvokeControl int `json:"invoke" default:"0"` // Specifies the regular expression matching rules. ChannelRegexp string `json:"channel_regexp"` }
ACLRule stores an access control rule to all channels matched with `ChannelRegexp`.
type KeyStore ¶
type KeyStore struct { Table map[string]*SessionKey `json:"table"` // contains filtered or unexported fields }
KeyStore - A structure to store a set of keys. This structure is thread-compatible.
func CreateKeyStore ¶
func CreateKeyStore() *KeyStore
CreateKeyStore initializes a key store in memory.
func LoadKeyStore ¶
LoadKeyStore will load configuration from disk.
func (*KeyStore) CheckPermission ¶
CheckPermission checks the permission of the header for given request type acting on the requested channel. We only examine the first key within the `header`.
func (*KeyStore) CleanUp ¶
func (store *KeyStore) CleanUp()
CleanUp serves as a garbage collection function that will remove all expired keys and remove all entries within cache.
func (*KeyStore) GenerateKeyAndRegister ¶
func (store *KeyStore) GenerateKeyAndRegister(name string, rules []ACLRule, duration time.Duration) string
GenerateKeyAndRegister generates a key and registers into the table.
func (*KeyStore) GetExpireTime ¶
GetExpireTime returns the expiration time of the key, if key is not registered, a past time will be returned.
func (*KeyStore) GetSessionKey ¶
func (store *KeyStore) GetSessionKey(key []byte) *SessionKey
GetSessionKey returns the matched key property.
func (*KeyStore) LoadKeyStore ¶ added in v0.0.27
LoadKeyStore replaces the keystore with the one on disk.
func (*KeyStore) RegisterKey ¶
func (store *KeyStore) RegisterKey(Key []byte, property SessionKey) error
RegisterKey registers a key into the KeyStore. Returns error if there is an existing unexpired key.
func (*KeyStore) Save ¶
Save dumps all configuration to the disk in JSON format WITHOUT any encryption.
func (*KeyStore) UpdateKey ¶
func (store *KeyStore) UpdateKey(Key []byte, property SessionKey)
UpdateKey updates the property of the Key, will create a new entry if Key does not exist.
type SessionKey ¶
type SessionKey struct { // Expiration time of the key. Expire time.Time `json:"expire"` // If there are multiple matching rules, takes the later one in the array. Rules []ACLRule `json:"rules"` // ID of this key, just for identification. ID string `json:"id"` // Description of this key. Description string `json:"description"` }
SessionKey represents the property of the key.