Struct jwt_compact_preview::Renamed [−][src]
pub struct Renamed<A> { /* fields omitted */ }
Algorithm that uses a custom name when creating and validating tokens.
Examples
use jwt_compact::{alg::{Hs256, Hs256Key}, prelude::*, Empty, Renamed}; let alg = Renamed::new(Hs256, "HS2"); let key = Hs256Key::from(b"super_secret_key_donut_steel" as &[_]); let token_string = alg.token(Header::default(), &Claims::empty(), &key).unwrap(); let token = UntrustedToken::try_from(token_string.as_str()).unwrap(); assert_eq!(token.algorithm(), "HS2"); // Note that the created token cannot be verified against the original algorithm // since the algorithm name recorded in the token header doesn't match. assert!(Hs256.validate_integrity::<Empty>(&token, &key).is_err()); // ...but the modified alg is working as expected. assert!(alg.validate_integrity::<Empty>(&token, &key).is_ok());
Implementations
Trait Implementations
impl<A: Algorithm> Algorithm for Renamed<A>
[src]
impl<A: Algorithm> Algorithm for Renamed<A>
[src]type SigningKey = A::SigningKey
Key used when issuing new tokens.
type VerifyingKey = A::VerifyingKey
Key used when verifying tokens. May coincide with SigningKey
for symmetric
algorithms (e.g., HS*
). Read more
type Signature = A::Signature
Signature produced by the algorithm.
fn name(&self) -> Cow<'static, str>
[src]
fn sign(
&self,
signing_key: &Self::SigningKey,
message: &[u8]
) -> Self::Signature
[src]
&self,
signing_key: &Self::SigningKey,
message: &[u8]
) -> Self::Signature
fn verify_signature(
&self,
signature: &Self::Signature,
verifying_key: &Self::VerifyingKey,
message: &[u8]
) -> bool
[src]
&self,
signature: &Self::Signature,
verifying_key: &Self::VerifyingKey,
message: &[u8]
) -> bool
Auto Trait Implementations
impl<A> RefUnwindSafe for Renamed<A> where
A: RefUnwindSafe,
impl<A> RefUnwindSafe for Renamed<A> where
A: RefUnwindSafe,
impl<A> UnwindSafe for Renamed<A> where
A: UnwindSafe,
impl<A> UnwindSafe for Renamed<A> where
A: UnwindSafe,
Blanket Implementations
impl<A> AlgorithmExt for A where
A: Algorithm,
[src]
impl<A> AlgorithmExt for A where
A: Algorithm,
[src]pub fn token<T>(
&Self,
Header,
&Claims<T>,
&<A as Algorithm>::SigningKey
) -> Result<String, CreationError> where
T: Serialize,
[src]
&Self,
Header,
&Claims<T>,
&<A as Algorithm>::SigningKey
) -> Result<String, CreationError> where
T: Serialize,
pub fn compact_token<T>(
&Self,
Header,
&Claims<T>,
&<A as Algorithm>::SigningKey
) -> Result<String, CreationError> where
T: Serialize,
[src]
&Self,
Header,
&Claims<T>,
&<A as Algorithm>::SigningKey
) -> Result<String, CreationError> where
T: Serialize,
pub fn validate_integrity<T>(
&Self,
&UntrustedToken<'_>,
&<A as Algorithm>::VerifyingKey
) -> Result<Token<T>, ValidationError> where
T: DeserializeOwned,
[src]
&Self,
&UntrustedToken<'_>,
&<A as Algorithm>::VerifyingKey
) -> Result<Token<T>, ValidationError> where
T: DeserializeOwned,
pub fn validate_for_signed_token<T>(
&Self,
&UntrustedToken<'_>,
&<A as Algorithm>::VerifyingKey
) -> Result<SignedToken<A, T>, ValidationError> where
T: DeserializeOwned,
[src]
&Self,
&UntrustedToken<'_>,
&<A as Algorithm>::VerifyingKey
) -> Result<SignedToken<A, T>, ValidationError> where
T: DeserializeOwned,
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,