db

package
v0.0.0-...-0db91f5 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GCMEncryptor

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

func NewGCMEncryptor

func NewGCMEncryptor(secret string) (GCMEncryptor, error)

func (GCMEncryptor) Decrypt

func (g GCMEncryptor) Decrypt(val string) (string, error)

func (GCMEncryptor) Encrypt

func (g GCMEncryptor) Encrypt(val string) (string, error)

type LimitedRedisClient

type LimitedRedisClient interface {

	// EXPIREAT key unix-time-seconds
	ExpireAt(ctx context.Context, key string, tm time.Time) *redis.BoolCmd
	// DEL key [key ...]
	Del(ctx context.Context, keys ...string) *redis.IntCmd
	// PERSIST key
	Persist(ctx context.Context, key string) *redis.BoolCmd

	// HGETALL key
	HGetAll(ctx context.Context, key string) *redis.MapStringStringCmd
	// HSET key field value [field value ...]
	HSet(ctx context.Context, key string, values ...any) *redis.IntCmd
}

LimitedRedisClient is the limited set of functionality expected from the redis client in this adapter. This allows for easy mocking and swapping of the client. The universal redis client interface is way too big.

type MockRedisAdapterOption

type MockRedisAdapterOption func(r *RedisAdapter)

func WithEncryption

func WithEncryption(key string) MockRedisAdapterOption

type MockRedisClient

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

Implements the LimitedRedis client struct Only suitable for testing The value set for the IntCmd or similar results is always 1 regardless of how many records were affected Contexts are completely ignored

func (*MockRedisClient) Del

func (m *MockRedisClient) Del(_ context.Context, keys ...string) *redis.IntCmd

func (*MockRedisClient) ExpireAt

func (m *MockRedisClient) ExpireAt(ctx context.Context, key string, tm time.Time) *redis.BoolCmd

func (*MockRedisClient) HGetAll

func (m *MockRedisClient) HGetAll(_ context.Context, key string) *redis.MapStringStringCmd

func (*MockRedisClient) HSet

func (m *MockRedisClient) HSet(_ context.Context, key string, values ...any) *redis.IntCmd

func (*MockRedisClient) Persist

func (m *MockRedisClient) Persist(ctx context.Context, key string) *redis.BoolCmd

type RedisAdapter

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

func NewMockRedisAdapter

func NewMockRedisAdapter(options ...MockRedisAdapterOption) RedisAdapter

func NewRedisAdapter

func NewRedisAdapter(options ...RedisAdapterOption) (*RedisAdapter, error)

func (RedisAdapter) GetAccessToken

func (r RedisAdapter) GetAccessToken(ctx context.Context, tokenID string) (models.AuthToken, error)

GetAccessToken reads the associated ID, access token value, expiration, tokenID and refresh URL of an access token from Redis

func (RedisAdapter) GetIDToken

func (r RedisAdapter) GetIDToken(ctx context.Context, tokenID string) (models.AuthToken, error)

func (RedisAdapter) GetRefreshToken

func (r RedisAdapter) GetRefreshToken(ctx context.Context, tokenID string) (models.AuthToken, error)

GetRefreshToken reads the associated ID, refresh token value, expiration and tokenID of a refresh token from Redis

func (RedisAdapter) GetSession

func (r RedisAdapter) GetSession(ctx context.Context, sessionID string) (models.Session, error)

func (RedisAdapter) RemoveSession

func (r RedisAdapter) RemoveSession(ctx context.Context, sessionID string) error

func (RedisAdapter) SetAccessToken

func (r RedisAdapter) SetAccessToken(ctx context.Context, token models.AuthToken) error

SetAccessToken writes the associated ID, access token value, expiration, tokenID and refresh URL of an access token to Redis.

func (RedisAdapter) SetAccessTokenExpiry

func (r RedisAdapter) SetAccessTokenExpiry(ctx context.Context, token models.AuthToken, expiresAt time.Time) error

func (RedisAdapter) SetIDToken

func (r RedisAdapter) SetIDToken(ctx context.Context, token models.AuthToken) error

func (RedisAdapter) SetIDTokenExpiry

func (r RedisAdapter) SetIDTokenExpiry(ctx context.Context, token models.AuthToken, expiresAt time.Time) error

func (RedisAdapter) SetRefreshToken

func (r RedisAdapter) SetRefreshToken(ctx context.Context, token models.AuthToken) error

SetRefreshToken writes the associated ID, access token value, expiration and tokenID of a refresh token to Redis

func (RedisAdapter) SetRefreshTokenExpiry

func (r RedisAdapter) SetRefreshTokenExpiry(ctx context.Context, token models.AuthToken, expiresAt time.Time) error

func (RedisAdapter) SetSession

func (r RedisAdapter) SetSession(ctx context.Context, session models.Session) error

type RedisAdapterOption

type RedisAdapterOption func(*RedisAdapter) error

func WithEcryption

func WithEcryption(secretKey string) RedisAdapterOption

func WithRedisConfig

func WithRedisConfig(redisConfig config.RedisConfig) RedisAdapterOption

Jump to

Keyboard shortcuts

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