Struct jwt_compact::Renamed [−][src]
pub struct Renamed<A> { /* fields omitted */ }
Expand description
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::new(b"super_secret_key_donut_steel");
let token_string = alg.token(Header::default(), &Claims::empty(), &key)?;
let token = UntrustedToken::new(&token_string)?;
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
type SigningKey = A::SigningKey
type SigningKey = A::SigningKey
Key used when issuing new tokens.
type VerifyingKey = A::VerifyingKey
type VerifyingKey = A::VerifyingKey
Key used when verifying tokens. May coincide with Self::SigningKey
for symmetric
algorithms (e.g., HS*
). Read more
Returns the name of this algorithm, as mentioned in the alg
field of the JWT header.
Signs a message
with the signing_key
.
fn verify_signature(
&self,
signature: &Self::Signature,
verifying_key: &Self::VerifyingKey,
message: &[u8]
) -> bool
fn verify_signature(
&self,
signature: &Self::Signature,
verifying_key: &Self::VerifyingKey,
message: &[u8]
) -> bool
Verifies the message
against the signature
and verifying_key
.
Auto Trait Implementations
impl<A> RefUnwindSafe for Renamed<A> where
A: RefUnwindSafe,
impl<A> UnwindSafe for Renamed<A> where
A: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more