Skip to main content

Authenticated

Struct Authenticated 

Source
pub struct Authenticated<T> {
    pub value: T,
    pub protected: JoseHeader,
    pub unprotected: Vec<Value>,
    /* private fields */
}
Expand description

A value that arrived under signature or AEAD authentication.

Fields are public because they are the answer, not because they are interchangeable: protected was integrity-protected by the operation that produced this value, and unprotected explicitly was not. Use the protected header for any decision — algorithm, key identity, content type, crit — and treat the unprotected entries as display-only metadata.

Fields§

§value: T

The verified payload, plaintext, or parsed claims.

§protected: JoseHeader

The protected header that was authenticated with this value.

This is the header the signature covered (or the JWE protected header the AEAD tag authenticated), parsed once by the verification path. It is not a re-parse of whatever bytes the caller still has.

§unprotected: Vec<Value>

Unauthenticated metadata carried by the document, verbatim.

A compact JWS carries none, so this is usually empty. A flattened or general JWS/JWE can carry several objects (the shared unprotected member plus a header member per signature/recipient); each is one entry here, in the order they appeared.

Never select a key, an algorithm, or a trust decision from these. They are not integrity-protected: a document that verifies perfectly can carry a hostile kid here.

Implementations§

Source§

impl<T> Authenticated<T>

Source

pub fn verified_key_index(&self) -> Option<usize>

Index of the JWK that verified this token, relative to the supplied set.

This identifies the successful candidate even in a kid-less fallback. It is not an identity or authorization claim. Single-key and JWE APIs return None; Self::map preserves it.

Source

pub fn into_value(self) -> T

Discard the header and keep the value.

Source

pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Authenticated<U>

Transform the value, keeping the header context.

Useful for parsing a verified payload into a domain type without losing the authenticated header next to it.

Source

pub fn algorithm(&self) -> &str

The authenticated alg value.

A convenience for the single most common header read after verification — and the reason it exists as a method is so that read does not have to reach for a header from somewhere else.

Source

pub fn kid(&self) -> Option<&str>

The kid from the authenticated header only.

Deliberately does not consult unprotected, unlike a PlainHeader-style getter that would search every object it can find.

Source

pub fn has_unprotected(&self) -> bool

true when the document carried any unauthenticated metadata.

A caller that logs “this document tried to tell me something outside the signature” can gate on this.

Trait Implementations§

Source§

impl<T: Clone> Clone for Authenticated<T>

Source§

fn clone(&self) -> Self

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<T: Debug> Debug for Authenticated<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Forget for Authenticated<T>

§

impl<T> Freeze for Authenticated<T>
where T: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze, PhantomData<Value>: Freeze, *const LeafNode<String, Value> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, Value)>>: Freeze, PhantomData<String>: Freeze,

§

impl<T> Move for Authenticated<T>

§

impl<T> RefUnwindSafe for Authenticated<T>
where T: RefUnwindSafe,

§

impl<T> Send for Authenticated<T>
where T: Send, RawVecInner: Send, NodeRef<Owned, String, Value, LeafOrInternal>: Send, BoxRaw<(String, Value)>: Send,

§

impl<T> Sync for Authenticated<T>
where T: Sync, RawVecInner: Sync, NodeRef<Owned, String, Value, LeafOrInternal>: Sync, BoxRaw<(String, Value)>: Sync,

§

impl<T> Unpin for Authenticated<T>
where T: Unpin, *const u8 is !null: Unpin, *const LeafNode<String, Value> is !null: Unpin, Box<(String, Value)>: Unpin,

§

impl<T> UnsafeUnpin for Authenticated<T>

§

impl<T> UnwindSafe for Authenticated<T>
where T: UnwindSafe, RawVecInner: UnwindSafe, BTreeMap<String, Value>: UnwindSafe,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.