Documentation
¶
Index ¶
- type Option
- type PersistentStorage
- func (p PersistentStorage) Bytes(key []byte) (res []byte, err error)
- func (p PersistentStorage) Close() error
- func (p PersistentStorage) Delete(key []byte) error
- func (p PersistentStorage) GetToken(ownerID user.ID, tokenID []byte) (t *session.PrivateToken)
- func (p PersistentStorage) MigrateOldTokenStorage(oldPath string) error
- func (p PersistentStorage) RemoveOldTokens(epoch uint64)
- func (p PersistentStorage) SetBytes(key []byte, value []byte) error
- func (p PersistentStorage) SetUInt32(key []byte, value uint32) error
- func (p PersistentStorage) Store(sk ecdsa.PrivateKey, usr user.ID, id []byte, exp uint64) error
- func (p PersistentStorage) UInt32(key []byte) (n uint32, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶ added in v0.50.0
type Option func(*cfg)
Option allows setting optional parameters of the TokenStore.
func WithEncryptionKey ¶ added in v0.50.0
func WithEncryptionKey(k *ecdsa.PrivateKey) Option
WithEncryptionKey return an option to encrypt private session keys using provided private key.
func WithLogger ¶ added in v0.50.0
WithLogger returns an option to specify logger.
func WithTimeout ¶ added in v0.50.0
WithTimeout returns option to specify database connection timeout.
type PersistentStorage ¶
type PersistentStorage struct {
// contains filtered or unexported fields
}
PersistentStorage is a wrapper around persistent K:V db that provides thread safe functions to set and fetch state variables of the Inner Ring and Storage applications and optionally allows creating (storing), retrieving and expiring (removing) session tokens.
func NewPersistentStorage ¶
func NewPersistentStorage(path string, withSessionStorage bool, opts ...Option) (*PersistentStorage, error)
NewPersistentStorage creates a new instance of a storage with 0o600 rights.
func (PersistentStorage) Bytes ¶ added in v0.39.0
func (p PersistentStorage) Bytes(key []byte) (res []byte, err error)
Bytes reads binary value by specified key. Returns nil if value is missing.
func (PersistentStorage) Close ¶
func (p PersistentStorage) Close() error
Close closes persistent database instance.
func (PersistentStorage) Delete ¶ added in v0.44.0
func (p PersistentStorage) Delete(key []byte) error
func (PersistentStorage) GetToken ¶ added in v0.50.0
func (p PersistentStorage) GetToken(ownerID user.ID, tokenID []byte) (t *session.PrivateToken)
GetToken returns private token corresponding to the given identifiers.
Returns nil is there is no element in storage.
func (PersistentStorage) MigrateOldTokenStorage ¶ added in v0.50.0
func (p PersistentStorage) MigrateOldTokenStorage(oldPath string) error
func (PersistentStorage) RemoveOldTokens ¶ added in v0.50.0
func (p PersistentStorage) RemoveOldTokens(epoch uint64)
RemoveOldTokens removes all tokens expired since provided epoch.
func (PersistentStorage) SetBytes ¶ added in v0.39.0
func (p PersistentStorage) SetBytes(key []byte, value []byte) error
SetBytes saves binary value in the storage by specified key.
func (PersistentStorage) SetUInt32 ¶
func (p PersistentStorage) SetUInt32(key []byte, value uint32) error
SetUInt32 sets a uint32 value in the storage.
func (PersistentStorage) Store ¶ added in v0.50.0
func (p PersistentStorage) Store(sk ecdsa.PrivateKey, usr user.ID, id []byte, exp uint64) error
Store saves parameterized private key in the underlying Bolt database. Private keys are encrypted if token store has been configured to.