Skip to main content

mint_session

Function mint_session 

Source
pub fn mint_session(
    signer: &SessionSigner,
    subject: &SessionSubject,
    scopes: &[SessionScope],
    now_ms: u64,
    ttl_ms: u64,
) -> String
Expand description

Mint a stateless, signed session token bound to subject, carrying scopes.

The token is base64url(payload_json) ++ "." ++ base64url(signature): the payload segment is plain (unprefixed) JSON, readable by anyone who holds the token but unforgeable — verify_session recomputes the domain-prefixed canonical from the parsed fields and checks signer’s ed25519 signature over it. expires_ms is now_ms + ttl_ms, saturating (never wraps on a pathological ttl_ms).

§Panics

Panics if scopes is empty — a session that authorizes nothing has no reason to exist; every caller names at least one scope explicitly.