Documentation
¶
Overview ¶
Package redis provides Redis-backed implementations of the challenge store and key store interfaces for distributed deployments.
This package requires a Redis client to be passed in, giving you full control over connection pooling, timeouts, and clustering configuration.
Supported Redis clients:
- github.com/redis/go-redis/v9
- Any client implementing the Cmdable interface
Index ¶
- type BoolCmd
- type ChallengeStore
- type ChallengeStoreConfig
- type Cmdable
- type IntCmd
- type KeyStore
- func (s *KeyStore) Delete(ctx context.Context, keyID string) error
- func (s *KeyStore) IncrementCounter(ctx context.Context, keyID string) (uint32, error)
- func (s *KeyStore) Load(ctx context.Context, keyID string) (*ios.StoredKey, error)
- func (s *KeyStore) Store(ctx context.Context, keyID string, key *ios.StoredKey) error
- type KeyStoreConfig
- type MapStringStringCmd
- type StatusCmd
- type StringCmd
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChallengeStore ¶
type ChallengeStore struct {
// contains filtered or unexported fields
}
ChallengeStore is a Redis-backed implementation of challenge.Store. Suitable for distributed deployments where multiple server instances need to share challenge state.
func NewChallengeStore ¶
func NewChallengeStore(cfg ChallengeStoreConfig) (*ChallengeStore, error)
NewChallengeStore creates a new Redis-backed challenge store.
func (*ChallengeStore) Close ¶
func (s *ChallengeStore) Close()
Close is a no-op for Redis store (connection is managed externally).
func (*ChallengeStore) Generate ¶
func (s *ChallengeStore) Generate(identifier string) (string, error)
Generate creates a new challenge for the given identifier.
func (*ChallengeStore) Validate ¶
func (s *ChallengeStore) Validate(identifier, challenge string) bool
Validate checks if the challenge is valid and consumes it. Returns true only if the challenge exists, matches, and hasn't expired.
type ChallengeStoreConfig ¶
type ChallengeStoreConfig struct {
// Client is the Redis client (required).
Client Cmdable
// KeyPrefix is prepended to all Redis keys (default: "attest:challenge:").
KeyPrefix string
// Timeout is how long challenges remain valid (default: 5 minutes).
Timeout time.Duration
// ChallengeBytes is the number of random bytes in a challenge (default: 32).
ChallengeBytes int
}
ChallengeStoreConfig holds configuration for the Redis challenge store.
type Cmdable ¶
type Cmdable interface {
Get(ctx context.Context, key string) StringCmd
Set(ctx context.Context, key string, value any, expiration time.Duration) StatusCmd
SetNX(ctx context.Context, key string, value any, expiration time.Duration) BoolCmd
Del(ctx context.Context, keys ...string) IntCmd
Incr(ctx context.Context, key string) IntCmd
HSet(ctx context.Context, key string, values ...any) IntCmd
HGet(ctx context.Context, key, field string) StringCmd
HGetAll(ctx context.Context, key string) MapStringStringCmd
HIncrBy(ctx context.Context, key, field string, incr int64) IntCmd
Expire(ctx context.Context, key string, expiration time.Duration) BoolCmd
}
Cmdable is the interface for Redis commands. This is compatible with github.com/redis/go-redis/v9.Client and ClusterClient.
type KeyStore ¶
type KeyStore struct {
// contains filtered or unexported fields
}
KeyStore is a Redis-backed implementation of ios.KeyStore. Suitable for distributed deployments where multiple server instances need to share attestation state.
func NewKeyStore ¶
func NewKeyStore(cfg KeyStoreConfig) (*KeyStore, error)
NewKeyStore creates a new Redis-backed key store.
func (*KeyStore) IncrementCounter ¶
IncrementCounter atomically increments and returns the new counter value.
type KeyStoreConfig ¶
type KeyStoreConfig struct {
// Client is the Redis client (required).
Client Cmdable
// KeyPrefix is prepended to all Redis keys (default: "attest:key:").
KeyPrefix string
// TTL is how long keys are stored (default: 0 = no expiration).
// Set this if you want keys to automatically expire.
TTL time.Duration
}
KeyStoreConfig holds configuration for the Redis key store.
type MapStringStringCmd ¶
MapStringStringCmd is the interface for map command results.