Countersign.Token (Countersign v0.1.0)

Copy Markdown View Source

Signing-link tokens: 32 random bytes, URL-safe base64 without padding.

Only the SHA-256 hash of a token is stored (signing_requests.token_hash); the token itself exists in the link and, encrypted, in last_token_ciphertext for the reminder.

Summary

Functions

A new token and its hash.

The SHA-256 hash of token (32 bytes).

Whether token has the shape generate/0 produces. A lookup checks this first, so a malformed path segment never reaches the database.

Functions

generate()

@spec generate() :: {token :: String.t(), hash :: binary()}

A new token and its hash.

hash(token)

@spec hash(String.t()) :: binary()

The SHA-256 hash of token (32 bytes).

valid_format?(token)

@spec valid_format?(term()) :: boolean()

Whether token has the shape generate/0 produces. A lookup checks this first, so a malformed path segment never reaches the database.