pub struct Keys { /* private fields */ }Expand description
Keys derived from the configured secrets. The first secret signs, verifies and encrypts.
Every secret decrypts, so encrypted columns stay readable after a rotation, and every
secret verifies a signed session token (Keys::verify_token), which is only a
pointer to a session row, so rotating signs nobody out. A retired secret can’t sign
anything self-contained (the cookie cache, plugin cookies) that is accepted.
Implementations§
Source§impl Keys
impl Keys
Sourcepub fn sign(&self, purpose: SignPurpose, value: &str) -> String
pub fn sign(&self, purpose: SignPurpose, value: &str) -> String
value.signature, signature base64url.
Sourcepub fn verify<'a>(
&self,
purpose: SignPurpose,
signed: &'a str,
) -> Option<&'a str>
pub fn verify<'a>( &self, purpose: SignPurpose, signed: &'a str, ) -> Option<&'a str>
The value, when the current (first) secret signed it. For values that carry their own meaning, like the cookie cache or a plugin’s signed cookie.
Sourcepub fn verify_token<'a>(&self, signed: &'a str) -> Option<&'a str>
pub fn verify_token<'a>(&self, signed: &'a str) -> Option<&'a str>
A session token signed with SignPurpose::Cookie by any configured secret. Only
for raw session tokens, and for markers that only restrict the session they come
with (the rememberMe: false flag): a token means nothing until its session row is
found, and a forged marker only shortens a session, so a retired secret can’t gain
anything, and values signed before a rotation keep working.