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

Creates a renamed algorithm.

Trait Implementations

Key used when issuing new tokens.

Key used when verifying tokens. May coincide with Self::SigningKey for symmetric algorithms (e.g., HS*). Read more

Signature produced by the algorithm.

Returns the name of this algorithm, as mentioned in the alg field of the JWT header.

Signs a message with the signing_key.

Verifies the message against the signature and verifying_key.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.