ProxyStateStore

A thread-safe in-memory store mapping a proxy state to the client's pending-authorization details. Entries are consumed (single use) on lookup so a relayed callback cannot be replayed.

The store is bounded so the unauthenticated /authorize route cannot grow process memory without limit: each entry carries an insertion timestamp, and every put/take sweeps entries older than the authorization-flow TTL and caps the live entry count, evicting the oldest by insertion time when the cap is reached. The clock is injectable so the bounds are unit-testable.

Constructors

this
this(Duration ttl, size_t maxEntries, MonoTime delegate() @(safe) clock)

Construct with explicit bounds and an optional injectable clock (used by tests to drive TTL expiry deterministically). A null clock uses MonoTime.currTime.

Members

Functions

length
size_t length()

Number of live pending authorizations (test/diagnostic use).

put
void put(string proxyState, ProxyAuthState st)

Record the client's authorization details under the proxy state.

take
ProxyAuthState take(string proxyState, bool found)

Consume and return the details for proxyState, setting found.

Variables

defaultMaxEntries
enum size_t defaultMaxEntries;

Maximum number of live pending authorizations. When reached on put, the oldest entries are evicted so a flood cannot exhaust memory inside the TTL.

defaultTtl
enum Duration defaultTtl;

Lifetime of a pending authorization (authorize -> consent -> callback). An abandoned or un-consented flow is swept after this elapses.