Struct Header

Source
pub struct Header {
    pub algorithm: Algorithm,
    pub key_id: Option<String>,
    pub obj_type: Option<String>,
    pub required_extensions: Option<Vec<String>>,
}

Fields§

§algorithm: Algorithm

The algorithm that this object is/will be signed with. Corresponds to the alg header parameter.

See section 4.1.1 of RFC 7515.

§key_id: Option<String>

The type of the object that is encoded with this header. Corresponds to the kid header parameter.

See section 4.1.4 of RFC 7515.

§obj_type: Option<String>

The type of the object that is encoded with this header. Corresponds to the typ header parameter.

See section 4.1.9 of RFC 7515.

§required_extensions: Option<Vec<String>>

A list of parameters, i.e. field names, that the JWS implementation (i.e. jwt2) is required to process. Corresponds to the crit header parameter.

This is a field that jwt2 doesn’t really support yet, but it is left in for the sake of being standards-compliant.

To validate this, use the Header::required_extensions function.

See section 4.1.11 of RFC 7515.

Implementations§

Source§

impl Header

Source

pub fn new(algorithm: Algorithm) -> Self

Source

pub fn recommended<R>(recommender: &R) -> Self

Source

pub fn supports_required_extensions(&self) -> bool

Checks if this library supports the required extensions.

§Implementation details

For now, this will return true if Self::required_extensions is Some.

This is standards-compliant and “correct” behaviour since if it returns true:

  1. the array is empty, which is not standards-compliant:

    Producers MUST NOT use the empty list [] as the crit value.

  2. the array contains headers which are technically supported by jwt2. At the moment, jwt2 only supports header parameters that are specified by the JWS RFC or those specified by the JWA RFC.

    Recipients MAY consider the JWS to be invalid if the critical list contains any Header Parameter names defined by this specification or JWA for use with JWS or if any other constraints on its use are violated.

  3. the array specifies any parameter that jwt2 does not recognise, being the genuinely correct case.

    If any of the listed extension Header Parameters are not understood and supported by the recipient, then the JWS is invalid.

In the future, however, this function should properly check if the parameters are handled.

Trait Implementations§

Source§

impl Clone for Header

Source§

fn clone(&self) -> Header

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'de> Deserialize<'de> for Header

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 Header

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§

§

impl Freeze for Header

§

impl RefUnwindSafe for Header

§

impl Send for Header

§

impl Sync for Header

§

impl Unpin for Header

§

impl UnwindSafe for Header

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

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

Source§

fn vzip(self) -> V

Source§

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