Limen.Challenge.Replay (limen v0.2.1)

Copy Markdown View Source

Makes every challenge token single-use.

Each instance remembers solved tokens in a Limen.Sketch.RotatingBloom that Limen.Challenge.Replay.Rotator rotates every challenge :ttl. A token is only valid for :ttl seconds, so it is always still remembered while it could be replayed. Memory is fixed by :replay_capacity; a false positive (one in a million at capacity) makes a legitimate client solve a fresh challenge.

Tokens are keyed by their MAC, which is unique per token, so remembering the token subsumes remembering each (token, nonce) pair.

Two verifications of the same token racing each other may both succeed (see Limen.Sketch.Bloom.put/2). Tokens are bound to the client identity, so that only gives one client a second pass it could have copied anyway.

Summary

Functions

Records the token identified by mac as used. Returns false if it already was.

Functions

use_once(instance, mac)

@spec use_once(Limen.Instance.t(), binary()) :: boolean()

Records the token identified by mac as used. Returns false if it already was.