Documentation
¶
Overview ¶
Package redisstore provides a store.KV CSRF token backend built on the native celeris driver/redis client. Tokens are persisted as their UTF-8 bytes under a configurable key prefix (default "csrf:").
The returned store implements store.GetAndDeleter via Redis GETDEL (Redis 6.2+). Callers with older Redis deployments can opt into a non-atomic GET+DEL fallback via [Options.OldRedisCompat].
Index ¶
- type Options
- type Store
- func (s *Store) Delete(ctx context.Context, key string) error
- func (s *Store) Get(ctx context.Context, key string) ([]byte, error)
- func (s *Store) GetAndDelete(ctx context.Context, key string) ([]byte, error)
- func (s *Store) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// KeyPrefix is prepended to every token key. Default: "csrf:".
KeyPrefix string
// OldRedisCompat enables a non-atomic GET+DEL fallback for
// GetAndDelete on Redis versions that do not support GETDEL
// (< 6.2). When true, single-use token validation is TOCTOU-
// susceptible under concurrent requests with the same token.
OldRedisCompat bool
}
Options configure the Redis-backed CSRF store.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a store.KV + store.GetAndDeleter backed by a *redis.Client.
func (*Store) GetAndDelete ¶
GetAndDelete implements store.GetAndDeleter atomically via GETDEL (Redis 6.2+). When [Options.OldRedisCompat] is true, falls back to a non-atomic GET+DEL pair.