pub struct SessionStore { /* private fields */ }Expand description
Encrypts/decrypts session payloads with a per-store AEAD key.
Supports key rotation: encode always uses the primary key, while decode
tries the primary first, then each retired fallback in order. This lets a
deployment rotate JERRYCAN_SECRET without invalidating sessions/tokens
minted under the previous key — the old key is moved to fallbacks until it
is fully retired (dropped from the list), at which point its ciphertexts stop
decrypting.
Implementations§
Source§impl SessionStore
impl SessionStore
Sourcepub fn new(key: &[u8; 32]) -> Self
pub fn new(key: &[u8; 32]) -> Self
Single-key store (no rotation). Equivalent to with_keys(key, &[]).
Sourcepub fn with_keys(primary: &[u8; 32], fallbacks: &[[u8; 32]]) -> Self
pub fn with_keys(primary: &[u8; 32], fallbacks: &[[u8; 32]]) -> Self
Rotation-aware store: encode uses primary; decode tries primary
then each entry of fallbacks in order. The first key that authenticates
the ciphertext wins.
Sourcepub fn encode<T: Serialize>(&self, value: &T) -> Result<String>
pub fn encode<T: Serialize>(&self, value: &T) -> Result<String>
Serialize + encrypt to a base64url token (no padding).
Sourcepub fn decode<T: DeserializeOwned>(&self, token: &str) -> Result<T>
pub fn decode<T: DeserializeOwned>(&self, token: &str) -> Result<T>
Decrypt + deserialize. Tries the primary key, then each rotation fallback
in order; the first key that authenticates wins. Any failure (bad base64,
short input, AEAD rejection under every key, JSON shape) is JC0401 —
an untrusted client value.
A Set-Cookie header value establishing the session (secure defaults).
A Set-Cookie header value clearing the session.
Extract the session cookie value from a Cookie request header.
Public so sibling crates (and the fuzz-smoke suite) can exercise the parser.
Trait Implementations§
Source§impl Clone for SessionStore
impl Clone for SessionStore
Source§fn clone(&self) -> SessionStore
fn clone(&self) -> SessionStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more