Skip to main content

Authentication

Struct Authentication 

Source
pub struct Authentication {
    pub auth_time: SystemTime,
    pub acr: Option<Box<str>>,
}
Available on crate feature consent only.
Expand description

What the HOST says about how, and when, it authenticated the resource owner.

This is a REPORT, not a proof. See the module docs: this crate cannot authenticate anyone and has no way to check this against anything, so it records it and holds requests to it.

Fields§

§auth_time: SystemTime

When the user actually authenticated. OpenID Connect Core section 2 defines auth_time as the “time when the End-User authentication occurred”, and RFC 9470 section 6 is what makes it worth carrying: max_age is meaningless without an instant to measure from. It is reported through both of that section’s channels, the JWT claim of 6.1 and the introspection member of 6.2.

NOT “when this request arrived”. A host that conflates the two makes every request look freshly authenticated, which is the one mistake that turns this whole mechanism into decoration.

§acr: Option<Box<str>>

The authentication context class the host says was satisfied: OpenID Connect Core section 2 acr. None means the host reported none, which can satisfy no acr_values request.

The VALUES are the host’s own vocabulary. This crate compares them as opaque strings and deliberately knows nothing about what any of them means: there is no registry it could check against, and a library that pretended to understand “phr” would be asserting something about a login flow it has never seen.

Box<str>, not String: written once at the moment the host reports it and never appended to. Same reasoning as crate::token::IssuedToken::jkt.

Implementations§

Source§

impl Authentication

Source

pub fn at(auth_time: SystemTime) -> Self

A report with no acr, for an authentication that happened at auth_time.

auth_time is WHEN THE USER ACTUALLY LOGGED IN, not when this request arrived, and this constructor is the place that distinction is lost or kept. Passing SystemTime::now() here on every request makes every login look seconds old, which satisfies every max_age a client can ask for and turns RFC 9470 step-up into decoration for that deployment. Nothing downstream can detect it: see the module docs on which half of this boundary is the host’s.

Source

pub fn with_acr(self, acr: &str) -> Self

Name the authentication context class this login satisfied.

&str rather than impl Into<String>: a generic here monomorphizes once per argument type at every call site, and the value is going into a Box<str> either way.

Source

pub fn age(&self, now: SystemTime) -> Option<Duration>

How old this authentication is at now, or None if it is stamped in the future.

A future auth_time is not an error here: clocks on separate machines disagree, and the one decision this feeds (AuthenticationRequirement::satisfied_by) reads None as “no elapsed time”, which is the reading that cannot lock a user out over a clock skew.

Trait Implementations§

Source§

impl Clone for Authentication

Source§

fn clone(&self) -> Authentication

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 Authentication

Source§

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

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

impl<'de> Deserialize<'de> for Authentication

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 Eq for Authentication

Source§

impl PartialEq for Authentication

Source§

fn eq(&self, other: &Authentication) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Authentication

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
Source§

impl StructuralPartialEq for Authentication

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<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<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> 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.