Skip to main content

Session

Struct Session 

Source
pub struct Session {
Show 14 fields pub session_id: String, pub did: String, pub challenge: String, pub state: SessionState, pub created_at: u64, pub last_seen: u64, pub refresh_token: Option<String>, pub refresh_expires_at: Option<u64>, pub tee_attested: bool, pub amr: Vec<String>, pub acr: String, pub acr_expires_at: Option<u64>, pub token_id: Option<String>, pub session_pubkey_b58btc: Option<String>,
}
Expand description

A session record stored in fjall under session:{session_id}.

Debug is hand-written below to redact the refresh_token. The raw derive would render it inline — any tracing::debug!("{session:?}"), panic backtrace, or dbg!() call holding a Session would otherwise exfiltrate a bearer-equivalent secret to logs.

Fields§

§session_id: String§did: String§challenge: String§state: SessionState§created_at: u64§last_seen: u64

Wall-clock epoch seconds of the most recent authenticated request on this session. Intrinsic-sender (DIDComm/TSP) sessions carry no refresh token, so this drives their idle-TTL expiry in cleanup_expired_sessions. REST sessions set it too but are bounded by refresh_expires_at. #[serde(default)] so rows written before this field existed deserialise with 0; the sweeper falls back to created_at in that case.

§refresh_token: Option<String>§refresh_expires_at: Option<u64>§tee_attested: bool

Whether the challenge issued for this session was accompanied by a successful TEE attestation. Distinct from “this VTA was built with the TEE feature”: a TEE binary running in TeeMode::Optional can serve unattested challenges when the provider errors out, and the resulting JWT must reflect that.

#[serde(default)] so older session records (written before this field existed) deserialize as false — the conservative default.

§amr: Vec<String>

AAL claims persisted across token rotation. Mirrors the JWT’s amr / acr so [/auth/refresh] mints a new access token at the same authentication-method-references and assurance level the session was last issued at. Without this, a session that was step-upped to aal2 would be silently dropped back to aal1 on every 15-minute refresh.

#[serde(default)] on both: a session row written before this field landed deserialises with empty vectors / empty string, which the refresh handler treats as “unknown AAL — fall back to aal1”. Same behaviour as pre-migration; the holder can re-step-up if needed.

§acr: String§acr_expires_at: Option<u64>

Epoch-seconds deadline after which a step-up elevation lapses. Set when a step-up ceremony elevates the session; None for a session that was never stepped up.

This — not acr — is what “a second factor was confirmed just now” means. acr records the level the session reached and stays there for its whole life (a passkey sign-in is aal2 from its first request, and refresh preserves it), so it cannot express freshness on its own.

Read by both transports, in the shape each needs:

  • Intrinsic-sender (DIDComm/TSP)resolve_did_session reads acr off this row on every message, so it rewrites the row via Session::downgrade_lapsed_elevation once the window closes.
  • RESTStepUpAuth reads the deadline directly via Session::elevation_active, so a stale acr on the row can never satisfy the gate and there is nothing to rewrite. acr is left alone, which keeps a passkey login honestly reported as aal2 rather than being downgraded below the level it logged in at.

#[serde(default)] for back-compat with pre-existing rows — which deserialise as “never stepped up”, the fail-closed reading.

§token_id: Option<String>

JWT jti rotation pin. Set per-token-issue so old JWTs are immediately invalidated when a new token is minted for the same session — the AuthClaims extractor compares the JWT’s jti against this field and rejects mismatches.

Optional because not every consumer uses per-token-issue rotation; the canonical extractor checks this only when Some(_). #[skip_serializing_if = "Option::is_none"] keeps the field out of the serialised form when unused so existing storage rows do not gain a token_id: null column.

§session_pubkey_b58btc: Option<String>

Ephemeral session pubkey for Data Integrity proof binding (eddsa-jcs-2022). Ed25519 multikey, base58btc with the z prefix (e.g. z6MkfBwQrx…). The corresponding did:key:<this> is the verificationMethod the holder uses when signing trust-task envelopes for this session.

None for clients that did not register a session pubkey; REQUIRED-spec dispatch then rejects proofless envelopes per the trust-task framework’s IS_PROOF_REQUIRED gate.

Implementations§

Source§

impl Session

Source

pub fn elevation_active(&self, now: u64) -> bool

Whether a step-up elevation is currently live on this session.

True only when acr_expires_at names a deadline that has not yet passed. An absent deadline is not a live elevation — it means this session was never stepped up (a passkey login, for instance, is aal2 from its first request and carries no window). Gates that need “a second factor was confirmed for this operation, just now” must consult this rather than acr, which stays elevated for the whole session and therefore cannot express freshness.

Fails closed: an unknown elevation time never reads as a recent one.

Source

pub fn downgrade_lapsed_elevation(&mut self, now: u64) -> bool

Drop a lapsed step-up elevation back to the un-elevated baseline, reporting whether anything changed.

Used by the intrinsic-sender resolver (resolve_did_session), where acr is read straight off this row on every message and so must be rewritten once the window closes. REST callers do not need this: their gate (StepUpAuth) reads the deadline itself, so a stale acr on the row can never satisfy it.

The baseline is the single did factor at aal1 — the level every intrinsic-sender session starts at in resolve_did_session.

Trait Implementations§

Source§

impl Clone for Session

Source§

fn clone(&self) -> Session

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Session

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Session

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Session

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more