Documentation
¶
Overview ¶
Package nonceprovider contains implementations of the login nonce store.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrStoreFull = errors.New("nonce store is at capacity")
ErrStoreFull is returned by Issue when the store is at capacity and no expired entries can be reclaimed. It signals transient overload, not a client error.
Functions ¶
This section is empty.
Types ¶
type InMemory ¶
type InMemory struct {
// contains filtered or unexported fields
}
InMemory is an in-process nonce store suitable for a single api-server replica. Nonces are keyed by the requesting address so a given address holds at most one live nonce. Nonces are short-lived, so losing them on restart is harmless; run more than one replica and this must be replaced with a shared (e.g. Postgres) store.
func NewInMemory ¶
NewInMemory creates an InMemory nonce store whose nonces expire after ttl.
func (*InMemory) Consume ¶
Consume removes the nonce and reports whether it was live at the moment of use.
func (*InMemory) Issue ¶
Issue returns a nonce for address. If the address already holds a live nonce it is returned unchanged, so repeat requests (retries, an attacker replaying the same address) do not grow the store. Otherwise a fresh nonce is minted. It purges expired entries on a fixed cadence and, when the store is full of live entries, returns ErrStoreFull instead of evicting another address's live nonce.