Documentation
¶
Index ¶
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)
}
func NewInMemoryLimiter ¶
func NewInMemoryLimiter(cfg LimiterConfig) AuthLimiter
type InMemoryLimiter ¶
type InMemoryLimiter struct {
// contains filtered or unexported fields
}
func (*InMemoryLimiter) AllowLoginAttempt ¶
func (*InMemoryLimiter) AllowSignupAttempt ¶
type LimiterConfig ¶
type RateLimitedError ¶
type RateLimitedError struct {
RetryAfter time.Duration
Scope string // "login:ip", "login:email", "signup:ip", "signup:email"
}
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.