Assertion

Struct Assertion 

Source
pub struct Assertion { /* private fields */ }
Expand description

Generates tokens by signing its specifics with a private key.

Tokens produced by the generator include a serialized version of the grant followed by an HMAC signature. Since data is not encrypted, this token generator will ERROR if any private extension is present in the grant.

The actual generator is given by a TaggedAssertion from Assertion::tag which enables signing the same grant for different uses, i.e. separating authorization from bearer grants and refresh tokens.

Implementations§

Source§

impl Assertion

Source

pub fn new(kind: AssertionKind, key: &[u8]) -> Self

Construct an assertion from a custom secret.

If the key material mismatches the key length required by the selected hash algorithm then padding or shortening of the supplied key material may be applied in the form dictated by the signature type. See the respective standards.

If future suites are added where this is not possible, this function may panic when supplied with an incorrect key length.

Currently, the implementation lacks the ability to really make use of another hasing mechanism than hmac + sha256.

Source

pub fn ephemeral() -> Self

Construct an assertion instance whose tokens are only valid for the program execution.

Source

pub fn tag<'a>(&'a self, tag: &'a str) -> TaggedAssertion<'a>

Get a reference to generator for the given tag.

Trait Implementations§

Source§

impl<'a> TagGrant for &'a Assertion

Source§

fn tag(&mut self, counter: u64, grant: &Grant) -> Result<String, ()>

For example sign the input parameters or generate a random token.
Source§

impl TagGrant for Assertion

Source§

fn tag(&mut self, counter: u64, grant: &Grant) -> Result<String, ()>

For example sign the input parameters or generate a random token.

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