storage

package
v0.0.0-...-982e07a Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBoltDBTokenStorage

func NewBoltDBTokenStorage(db *bolt.DB) common.TokenStorage

NewBoltDBTokenStorage return token storage using boltDB

func NewRedisClient

func NewRedisClient(hostport, password string, db int, tlsConfig *tls.Config) (*redis.Client, error)

NewRedisClient return new redis client

func WrapStorageWithEncryption

func WrapStorageWithEncryption(storage common.TokenStorage, encryptor TokenEncryptor) common.TokenStorage

WrapStorageWithEncryption return storage as wrapper which encrypts data before saving and decrypt after fetching data from wrapped storage

Types

type MemoryTokenStorage

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

MemoryTokenStorage implements TokenStorage and store data in process memory

func NewMemoryTokenStorage

func NewMemoryTokenStorage() (*MemoryTokenStorage, error)

NewMemoryTokenStorage return new memory token storage

func (*MemoryTokenStorage) Get

func (m *MemoryTokenStorage) Get(id []byte, context common.TokenContext) ([]byte, error)

Get data with defined id and context

func (*MemoryTokenStorage) Save

func (m *MemoryTokenStorage) Save(id []byte, context common.TokenContext, data []byte) error

Save data with defined id and context

func (*MemoryTokenStorage) SetAccessTimeGranularity

func (m *MemoryTokenStorage) SetAccessTimeGranularity(granularity time.Duration) error

SetAccessTimeGranularity sets access time granularity.

func (*MemoryTokenStorage) Stat

Stat returns metadata of a token entry.

func (*MemoryTokenStorage) VisitMetadata

func (m *MemoryTokenStorage) VisitMetadata(cb func(dataLength int, metadata common.TokenMetadata) (common.TokenAction, error)) error

VisitMetadata over token metadata in the storage.

type RedisStorage

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

RedisStorage implements TokenStorage using Redis as storage backend

func NewRedisStorage

func NewRedisStorage(client *redis.Client) (*RedisStorage, error)

NewRedisStorage return new redis storage for tokens using client

func (*RedisStorage) Get

func (m *RedisStorage) Get(id []byte, context common.TokenContext) ([]byte, error)

Get data with defined id and context

func (*RedisStorage) Save

func (m *RedisStorage) Save(id []byte, context common.TokenContext, data []byte) error

Save data with defined id and context

func (*RedisStorage) SetAccessTimeGranularity

func (m *RedisStorage) SetAccessTimeGranularity(granularity time.Duration) error

SetAccessTimeGranularity sets access time granularity.

func (*RedisStorage) Stat

func (m *RedisStorage) Stat(id []byte, context common.TokenContext) (common.TokenMetadata, error)

Stat returns metadata of a token entry.

func (*RedisStorage) VisitMetadata

func (m *RedisStorage) VisitMetadata(cb func(dataLength int, metadata common.TokenMetadata) (common.TokenAction, error)) error

VisitMetadata over token metadata in the storage.

type TokenEncryptor

type TokenEncryptor interface {
	Encrypt(data []byte, ctx common.TokenContext) ([]byte, error)
	Decrypt(data []byte, ctx common.TokenContext) ([]byte, error)
}

TokenEncryptor interface used by storage implementations to encrypt data before saving

func NewSCellEncryptor

func NewSCellEncryptor(tokenKeystore keystore.SymmetricEncryptionKeyStore) (TokenEncryptor, error)

NewSCellEncryptor return new TokenEncryptor implementation with SecureCell usage

Jump to

Keyboard shortcuts

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