Documentation
¶
Overview ¶
Package csrf provides CSRF protection for web handlers
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInvalidToken indicates a missing or invalid CSRF token ErrInvalidToken = errors.New("invalid csrf token") // ErrTokenExpired indicates the CSRF token has expired ErrTokenExpired = errors.New("csrf token expired") )
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles CSRF token generation and validation
func NewManager ¶
NewManager creates a new CSRF token manager
func (*Manager) CheckHealth ¶
CheckHealth verifies the CSRF manager is operational
func (*Manager) GenerateToken ¶
GenerateToken creates and stores a new CSRF token
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
RedisStore implements the Store interface using Redis
func (*RedisStore) CheckHealth ¶
func (s *RedisStore) CheckHealth(ctx context.Context) error
CheckHealth verifies Redis connectivity
func (*RedisStore) ValidateToken ¶
func (s *RedisStore) ValidateToken(ctx context.Context, token string) error
ValidateToken checks if a token exists and has not expired
type Store ¶
type Store interface { // SaveToken stores a CSRF token with expiry SaveToken(ctx context.Context, token string, expiresIn time.Duration) error // ValidateToken checks if a token exists and is valid ValidateToken(ctx context.Context, token string) error // CheckHealth verifies the store is operational CheckHealth(ctx context.Context) error }
Store provides token storage operations
func NewRedisStore ¶
func NewRedisStore(client *redis.Client) Store
NewRedisStore creates a new Redis-backed CSRF token store
Click to show internal directories.
Click to hide internal directories.