pub struct KeycloakSession {
pub issuer: String,
pub client_id: String,
pub refresh_token: String,
pub access_token: String,
pub access_expires_at: i64,
}Expand description
A live Keycloak session for the human who ran tracevault login.
issuer and client_id are stored alongside the tokens because a
refresh needs them and must not depend on the TraceVault server being
reachable to re-read its public config.
Fields§
§issuer: String§client_id: String§refresh_token: StringSECRET. Long-lived (offline_access); this is the credential that
makes unattended hooks work.
access_token: StringSECRET. Short-lived bearer presented to the TraceVault server.
access_expires_at: i64Absolute unix seconds at which access_token stops being valid.
Implementations§
Source§impl KeycloakSession
impl KeycloakSession
Sourcepub fn needs_refresh(&self, now: i64) -> bool
pub fn needs_refresh(&self, now: i64) -> bool
Whether access_token is expired or close enough to expiry
(REFRESH_WINDOW_SECS) that it should be refreshed before use.
now is passed in rather than read from the clock so callers — and
tests of the window boundary — are deterministic.
Sourcepub fn apply(&mut self, tokens: &TokenSet, now: i64)
pub fn apply(&mut self, tokens: &TokenSet, now: i64)
Fold a fresh token response into this session.
A token endpoint may omit refresh_token when it doesn’t rotate
refresh tokens; the previous one is kept in that case, since dropping
it would silently downgrade the session to “expires in 5 minutes”.
Trait Implementations§
Source§impl Clone for KeycloakSession
impl Clone for KeycloakSession
Source§fn clone(&self) -> KeycloakSession
fn clone(&self) -> KeycloakSession
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for KeycloakSession
Hand-written so no {:?} can leak either token.
impl Debug for KeycloakSession
Hand-written so no {:?} can leak either token.