Skip to main content

Claims

Struct Claims 

Source
pub struct Claims {
    pub issuer: Option<Subject>,
    pub audience: Option<Subject>,
    pub expires_at: Option<UnixTime>,
    pub issued_at: UnixTime,
    pub message_id: MessageId,
    pub sender_key_id: Option<KeyId>,
    pub response_key_id: Option<KeyId>,
    pub response_subject: Option<ResponseSubject>,
    pub in_reply_to: Option<MessageId>,
    pub request_hash: Option<RequestHash>,
}
Expand description

The claim set carried in a protected header (CWT map, header 15, plus the basil private labels).

One struct for every role; MessageRole validators enforce which fields must / must not be present.

Fields§

§issuer: Option<Subject>

CWT iss (1).

§audience: Option<Subject>

CWT aud (3).

§expires_at: Option<UnixTime>

CWT exp (4); when absent the effective expiry is iat + default_ttl from ValidationParams.

§issued_at: UnixTime

CWT iat (6). Required.

§message_id: MessageId

CWT cti (7). Required; sender-unique inside the replay window.

§sender_key_id: Option<KeyId>

-70003: must equal the outer kid on signed/sealed messages.

§response_key_id: Option<KeyId>

-70004: the key a response must be sealed to (requests).

§response_subject: Option<ResponseSubject>

-70005: where to deliver the response (requests, optional).

§in_reply_to: Option<MessageId>

-70001: the request message id this message answers (responses).

§request_hash: Option<RequestHash>

-70002: SHA3-256 of the complete request bytes (responses).

Implementations§

Source§

impl Claims

Source

pub fn validate(&self, params: &ValidationParams) -> Result<(), ClaimsError>

Validate this claim set against params: clock-skew on iat, effective expiry (iat + default_ttl when exp is absent), the max_ttl cap on an explicit span, the audience allow-list, and the role shape.

§Errors

The first ClaimsError encountered, in the order above.

Source

pub fn validate_role(&self, role: MessageRole) -> Result<(), ClaimsError>

Validate only the role shape (which basil labels must / must not be present). Builders run this before sealing.

§Errors

ClaimsError::MissingClaim / ClaimsError::ForbiddenClaim with the offending label.

Trait Implementations§

Source§

impl Clone for Claims

Source§

fn clone(&self) -> Claims

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 Claims

Source§

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

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

impl Eq for Claims

Source§

impl PartialEq for Claims

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Claims

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