Documentation
¶
Overview ¶
Package ratelimit defines the rate-limit integration point of Auth-All. Auth-All does not require a specific backend.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decider ¶ added in v0.3.0
type Decider interface {
Limiter
// Decide counts one attempt and returns the decision.
Decide(ctx context.Context, key Key) (Decision, error)
}
Decider is an optional limiter interface that names a retry time.
A limiter that implements it drives the Retry-After header of a refused request. A limiter that implements Limiter only keeps the v1 behavior, and Auth-All sends Retry-After: 60.
type Decision ¶ added in v0.3.0
type Decision struct {
// Allowed reports whether the attempt can proceed.
Allowed bool
// RetryAfter is the time until the next attempt can succeed. It is zero
// when the attempt is allowed.
RetryAfter time.Duration
}
Decision is the answer of a Decider.
type LimiterFunc ¶
LimiterFunc adapts a function to the Limiter interface.
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
Memory is an in-process fixed-window limiter.
Memory is for local development and tests only. It is not sufficient for a distributed production deployment because each process keeps its own counters.
type Operation ¶
type Operation string
Operation names a sensitive flow.
const ( OpSignIn Operation = "sign-in" OpSignUp Operation = "sign-up" OpPasswordForgot Operation = "password-forgot" OpEmailVerify Operation = "email-verification-send" OpMagicLinkRequest Operation = "magic-link-request" OpPasswordChange Operation = "password-change" OpEmailChange Operation = "email-change" OpUserDelete Operation = "user-delete" OpTOTP Operation = "totp" )
Sensitive operations.
type Rule ¶ added in v0.3.0
type Rule struct {
// Operation names the flow that the rule counts.
Operation Operation
// Scope names the counted subject.
Scope Scope
// Limit is the number of accepted attempts in one window.
Limit int
// Window is the length of the counting window.
Window time.Duration
}
Rule is one limit of one operation.
func DefaultSignInRules ¶ added in v0.3.0
func DefaultSignInRules() []Rule
DefaultSignInRules returns the default rules of the sign-in flow. They allow 5 attempts for each email in 15 minutes, and 20 attempts for each client address in 1 minute.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package storelimit is a rate limiter that keeps its counters in the Auth-All database.
|
Package storelimit is a rate limiter that keeps its counters in the Auth-All database. |