module

Authly::StateStore

Single-use values with a lifetime (consent and device form nonces).

consume is the only check handlers make, so it has to be atomic: of several concurrent callers (also across processes, for a shared store) exactly one gets true. Implement it as one delete-and-report operation (Redis DEL returning 1, SQL DELETE ... WHERE with affected rows), never as valid? followed by a delete. With more than one node the store must be shared.

Instance methods

consume(state : String) : Bool

true when state was stored, has not expired and has not been consumed before

Source
store(state : String, ttl : Time::Span = 5.minutes)
Source
valid?(state : String) : Bool

Informational only: Authly's handlers never call it (a check followed by consume is not atomic).

Source