Skip to main content

verify_session

Function verify_session 

Source
pub fn verify_session(
    signer_public_key: &[u8],
    token: &str,
    now_ms: u64,
    denylist: &RevokedTokens,
) -> Option<SessionClaims>
Expand description

Verify a session token minted by mint_session, returning its SessionClaims on success.

Fail-closed on ALL of: malformed shape (not exactly one .), undecodable base64/JSON, a missing/wrong-typed/unrecognized-scope field, a signature that does not verify against signer_public_key under the domain-separated canonical (session_canonical — so a signature minted for any OTHER artifact kind this signer produces can never verify here), now_ms >= expires_ms (expiry is checked against the PARSED expires_ms, not trusted from wall-clock drift elsewhere), or the token being present in denylist (logout). No naive secret comparison happens here — unforgeability comes from the ed25519 signature check, not from string equality, so the denylist membership check needs no constant-time treatment: a token that fails to verify or fails the denylist check reveals nothing an attacker could use to forge a different one.

Needs only signer_public_key — no server-side session store, so this survives a cold restart of whatever process minted the token unchanged.