Documentation
¶
Overview ¶
Package cache provides rate limiting and throttling abstractions for the magic link plugin.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HashIdentifier ¶
HashIdentifier produces an opaque hash of the identifier to avoid storing plaintext emails in cache keys.
Types ¶
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
Limiter is a cache-backed rate limiter implementation.
func NewLimiter ¶
NewLimiter creates a new Limiter backed by an optional cache.
type RateLimiter ¶
type RateLimiter interface {
// CheckRateLimit verifies if an email is permitted to request a magic link.
// Returns true if allowed, false if rate limited.
CheckRateLimit(ctx context.Context, email string, maxRequests int, window time.Duration) (bool, error)
// CheckAndSetCooldown verifies if cooldown is active, and if not sets it.
// Returns true if allowed, false if cooldown is active.
CheckAndSetCooldown(ctx context.Context, email string, cooldown time.Duration) (bool, error)
}
RateLimiter enforces rate limiting and cooldown rules for magic link requests.
Click to show internal directories.
Click to hide internal directories.