pub struct StrongAlg<T>(pub T);Expand description
Wrapper around a JWT algorithm signalling that it supports only StrongKeys.
The wrapper will implement Algorithm if the wrapped value is an Algorithm with both
signing and verifying keys convertible to StrongKeys.
§Examples
let weak_key = Hs256Key::new(b"too short!");
assert!(StrongKey::try_from(weak_key).is_err());
// There is no way to create a `StrongKey` from `weak_key`!
let strong_key: StrongKey<_> = Hs256Key::generate(&mut thread_rng());
let claims = // ...
let token = StrongAlg(Hs256)
.token(&Header::empty(), &claims, &strong_key)?;Tuple Fields§
§0: TTrait Implementations§
Source§impl<T> Algorithm for StrongAlg<T>where
T: Algorithm,
StrongKey<<T as Algorithm>::SigningKey>: TryFrom<<T as Algorithm>::SigningKey>,
StrongKey<<T as Algorithm>::VerifyingKey>: TryFrom<<T as Algorithm>::VerifyingKey>,
impl<T> Algorithm for StrongAlg<T>where
T: Algorithm,
StrongKey<<T as Algorithm>::SigningKey>: TryFrom<<T as Algorithm>::SigningKey>,
StrongKey<<T as Algorithm>::VerifyingKey>: TryFrom<<T as Algorithm>::VerifyingKey>,
Source§type SigningKey = StrongKey<<T as Algorithm>::SigningKey>
type SigningKey = StrongKey<<T as Algorithm>::SigningKey>
Key used when issuing new tokens.
Source§type VerifyingKey = StrongKey<<T as Algorithm>::VerifyingKey>
type VerifyingKey = StrongKey<<T as Algorithm>::VerifyingKey>
Key used when verifying tokens. May coincide with
Self::SigningKey for symmetric
algorithms (e.g., HS*).Source§fn name(&self) -> Cow<'static, str>
fn name(&self) -> Cow<'static, str>
Returns the name of this algorithm, as mentioned in the
alg field of the JWT header.impl<T> Copy for StrongAlg<T>where
T: Copy,
Auto Trait Implementations§
impl<T> Freeze for StrongAlg<T>where
T: Freeze,
impl<T> RefUnwindSafe for StrongAlg<T>where
T: RefUnwindSafe,
impl<T> Send for StrongAlg<T>where
T: Send,
impl<T> Sync for StrongAlg<T>where
T: Sync,
impl<T> Unpin for StrongAlg<T>where
T: Unpin,
impl<T> UnwindSafe for StrongAlg<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<A> AlgorithmExt for Awhere
A: Algorithm,
impl<A> AlgorithmExt for Awhere
A: Algorithm,
Source§fn token<T>(
&self,
header: &Header<impl Serialize>,
claims: &Claims<T>,
signing_key: &<A as Algorithm>::SigningKey,
) -> Result<String, CreationError>where
T: Serialize,
fn token<T>(
&self,
header: &Header<impl Serialize>,
claims: &Claims<T>,
signing_key: &<A as Algorithm>::SigningKey,
) -> Result<String, CreationError>where
T: Serialize,
Creates a new token and serializes it to string.
Source§fn validator<'a, T>(
&'a self,
verifying_key: &'a <A as Algorithm>::VerifyingKey,
) -> Validator<'a, A, T>
fn validator<'a, T>( &'a self, verifying_key: &'a <A as Algorithm>::VerifyingKey, ) -> Validator<'a, A, T>
Creates a JWT validator for the specified verifying key and the claims type.
The validator can then be used to validate integrity of one or more tokens.
Source§fn validate_integrity<T>(
&self,
token: &UntrustedToken,
verifying_key: &<A as Algorithm>::VerifyingKey,
) -> Result<Token<T>, ValidationError>where
T: DeserializeOwned,
fn validate_integrity<T>(
&self,
token: &UntrustedToken,
verifying_key: &<A as Algorithm>::VerifyingKey,
) -> Result<Token<T>, ValidationError>where
T: DeserializeOwned,
👎Deprecated: Use
.validator().validate() for added flexibilityValidates the token integrity against the provided
verifying_key.Source§fn validate_for_signed_token<T>(
&self,
token: &UntrustedToken,
verifying_key: &<A as Algorithm>::VerifyingKey,
) -> Result<SignedToken<A, T>, ValidationError>where
T: DeserializeOwned,
fn validate_for_signed_token<T>(
&self,
token: &UntrustedToken,
verifying_key: &<A as Algorithm>::VerifyingKey,
) -> Result<SignedToken<A, T>, ValidationError>where
T: DeserializeOwned,
👎Deprecated: Use
.validator().validate_for_signed_token() for added flexibilityValidates the token integrity against the provided
verifying_key. Read moreSource§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
Source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
Source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
Source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
Consume self to return an equivalent value of
T. Read moreSource§impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
type Error = <U as TryFromKey<T>>::Error
fn try_into_key(self) -> Result<U, <U as TryFromKey<T>>::Error>
Source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
The counterpart to
unchecked_from.Source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
Source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
Consume self to return an equivalent value of
T.