persistent

package
v0.46.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2025 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*cfg)

Option allows setting optional parameters of the TokenStore.

func WithEncryptionKey

func WithEncryptionKey(k *ecdsa.PrivateKey) Option

WithEncryptionKey return an option to encrypt private session keys using provided private key.

func WithLogger

func WithLogger(v *zap.Logger) Option

WithLogger returns an option to specify logger.

func WithTimeout

func WithTimeout(v time.Duration) Option

WithTimeout returns option to specify database connection timeout.

type TokenStore

type TokenStore struct {
	// contains filtered or unexported fields
}

TokenStore is a wrapper around persistent K:V db that allows creating (storing), retrieving and expiring (removing) session tokens.

func NewTokenStore

func NewTokenStore(path string, opts ...Option) (*TokenStore, error)

NewTokenStore creates, initializes and returns a new TokenStore instance.

The elements of the instance are stored in bolt DB.

func (*TokenStore) Close

func (s *TokenStore) Close() error

Close closes database connection.

func (*TokenStore) Get

func (s *TokenStore) Get(ownerID user.ID, tokenID []byte) (t *storage.PrivateToken)

Get returns private token corresponding to the given identifiers.

Returns nil is there is no element in storage.

func (*TokenStore) RemoveOld

func (s *TokenStore) RemoveOld(epoch uint64)

RemoveOld removes all tokens expired since provided epoch.

func (*TokenStore) Store added in v0.45.0

func (s *TokenStore) 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 TokenStore has been configured to.

Jump to

Keyboard shortcuts

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