Documentation
¶
Index ¶
- type AuthLimiter
- type CacheLimiter
- func (l *CacheLimiter) AllowChallengeResendAttempt(ctx context.Context, ip net.IP) (bool, error)
- func (l *CacheLimiter) AllowChallengeVerifyAttempt(ctx context.Context, ip net.IP) (bool, error)
- func (l *CacheLimiter) AllowLoginAttempt(ctx context.Context, ip net.IP, email string) (bool, error)
- func (l *CacheLimiter) AllowPasskeyLoginAttempt(ctx context.Context, ip net.IP) (bool, error)
- func (l *CacheLimiter) AllowPasswordResetAttempt(ctx context.Context, ip net.IP, email string) (bool, error)
- func (l *CacheLimiter) AllowSignupAttempt(ctx context.Context, ip net.IP, email string) (bool, error)
- type InMemoryLimiter
- func (l *InMemoryLimiter) AllowChallengeResendAttempt(_ context.Context, ip net.IP) (bool, error)
- func (l *InMemoryLimiter) AllowChallengeVerifyAttempt(_ context.Context, ip net.IP) (bool, error)
- func (l *InMemoryLimiter) AllowLoginAttempt(_ context.Context, ip net.IP, email string) (bool, error)
- func (l *InMemoryLimiter) AllowPasskeyLoginAttempt(_ context.Context, ip net.IP) (bool, error)
- func (l *InMemoryLimiter) AllowPasswordResetAttempt(_ context.Context, ip net.IP, email string) (bool, error)
- func (l *InMemoryLimiter) AllowSignupAttempt(_ context.Context, ip net.IP, email string) (bool, error)
- type LimiterConfig
- type RateLimitedError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthLimiter ¶
type AuthLimiter interface {
AllowLoginAttempt(ctx context.Context, ip net.IP, email string) (bool, error)
AllowSignupAttempt(ctx context.Context, ip net.IP, email string) (bool, error)
AllowPasswordResetAttempt(ctx context.Context, ip net.IP, email string) (bool, error)
AllowPasskeyLoginAttempt(ctx context.Context, ip net.IP) (bool, error)
AllowChallengeVerifyAttempt(ctx context.Context, ip net.IP) (bool, error)
AllowChallengeResendAttempt(ctx context.Context, ip net.IP) (bool, error)
}
func NewCacheLimiter ¶ added in v0.1.21
func NewCacheLimiter(c cache.Counter, cfg LimiterConfig) AuthLimiter
func NewInMemoryLimiter ¶
func NewInMemoryLimiter(cfg LimiterConfig) AuthLimiter
type CacheLimiter ¶ added in v0.1.21
type CacheLimiter struct {
// contains filtered or unexported fields
}
func (*CacheLimiter) AllowChallengeResendAttempt ¶ added in v0.1.21
func (*CacheLimiter) AllowChallengeVerifyAttempt ¶ added in v0.1.21
func (*CacheLimiter) AllowLoginAttempt ¶ added in v0.1.21
func (*CacheLimiter) AllowPasskeyLoginAttempt ¶ added in v0.1.21
func (*CacheLimiter) AllowPasswordResetAttempt ¶ added in v0.1.21
func (*CacheLimiter) AllowSignupAttempt ¶ added in v0.1.21
type InMemoryLimiter ¶
type InMemoryLimiter struct {
// contains filtered or unexported fields
}
func (*InMemoryLimiter) AllowChallengeResendAttempt ¶ added in v0.1.18
func (*InMemoryLimiter) AllowChallengeVerifyAttempt ¶ added in v0.1.18
func (*InMemoryLimiter) AllowLoginAttempt ¶
func (*InMemoryLimiter) AllowPasskeyLoginAttempt ¶ added in v0.1.21
func (*InMemoryLimiter) AllowPasswordResetAttempt ¶ added in v0.1.18
func (*InMemoryLimiter) AllowSignupAttempt ¶
type LimiterConfig ¶
type LimiterConfig struct {
LoginIPLimit int
LoginIPWindow time.Duration
LoginEmailLimit int
LoginEmailWindow time.Duration
SignupIPLimit int
SignupIPWindow time.Duration
SignupEmailLimit int
SignupEmailWindow time.Duration
PasswordResetIPLimit int
PasswordResetIPWindow time.Duration
PasswordResetEmailLimit int
PasswordResetEmailWindow time.Duration
PasskeyLoginIPLimit int
PasskeyLoginIPWindow time.Duration
ChallengeVerifyIPLimit int
ChallengeVerifyIPWindow time.Duration
ChallengeResendIPLimit int
ChallengeResendIPWindow time.Duration
CleanupEvery int
MaxEntries int
}
type RateLimitedError ¶
RateLimitedError is returned when the caller should reject the attempt. RetryAfter can be used to set HTTP Retry-After header or show a UI message.
func IsRateLimited ¶
func IsRateLimited(err error) (*RateLimitedError, bool)
func (*RateLimitedError) Error ¶
func (e *RateLimitedError) Error() string
Click to show internal directories.
Click to hide internal directories.