Trait jwt_compact::AlgorithmExt
source · pub trait AlgorithmExt: Algorithm {
// Required methods
fn token<T>(
&self,
header: &Header<impl Serialize>,
claims: &Claims<T>,
signing_key: &Self::SigningKey,
) -> Result<String, CreationError>
where T: Serialize;
fn compact_token<T>(
&self,
header: &Header<impl Serialize>,
claims: &Claims<T>,
signing_key: &Self::SigningKey,
) -> Result<String, CreationError>
where T: Serialize;
fn validator<'a, T>(
&'a self,
verifying_key: &'a Self::VerifyingKey,
) -> Validator<'a, Self, T>;
fn validate_integrity<T>(
&self,
token: &UntrustedToken<'_>,
verifying_key: &Self::VerifyingKey,
) -> Result<Token<T>, ValidationError>
where T: DeserializeOwned;
fn validate_for_signed_token<T>(
&self,
token: &UntrustedToken<'_>,
verifying_key: &Self::VerifyingKey,
) -> Result<SignedToken<Self, T>, ValidationError>
where T: DeserializeOwned;
}
Expand description
Automatically implemented extensions of the Algorithm
trait.
Required Methods§
sourcefn token<T>(
&self,
header: &Header<impl Serialize>,
claims: &Claims<T>,
signing_key: &Self::SigningKey,
) -> Result<String, CreationError>where
T: Serialize,
fn token<T>(
&self,
header: &Header<impl Serialize>,
claims: &Claims<T>,
signing_key: &Self::SigningKey,
) -> Result<String, CreationError>where
T: Serialize,
Creates a new token and serializes it to string.
sourcefn compact_token<T>(
&self,
header: &Header<impl Serialize>,
claims: &Claims<T>,
signing_key: &Self::SigningKey,
) -> Result<String, CreationError>where
T: Serialize,
Available on crate feature ciborium
only.
fn compact_token<T>(
&self,
header: &Header<impl Serialize>,
claims: &Claims<T>,
signing_key: &Self::SigningKey,
) -> Result<String, CreationError>where
T: Serialize,
ciborium
only.Creates a new token with CBOR-encoded claims and serializes it to string.
sourcefn validator<'a, T>(
&'a self,
verifying_key: &'a Self::VerifyingKey,
) -> Validator<'a, Self, T>
fn validator<'a, T>( &'a self, verifying_key: &'a Self::VerifyingKey, ) -> Validator<'a, Self, 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.
sourcefn validate_integrity<T>(
&self,
token: &UntrustedToken<'_>,
verifying_key: &Self::VerifyingKey,
) -> Result<Token<T>, ValidationError>where
T: DeserializeOwned,
👎Deprecated: Use .validator().validate()
for added flexibility
fn validate_integrity<T>(
&self,
token: &UntrustedToken<'_>,
verifying_key: &Self::VerifyingKey,
) -> Result<Token<T>, ValidationError>where
T: DeserializeOwned,
.validator().validate()
for added flexibilityValidates the token integrity against the provided verifying_key
.
sourcefn validate_for_signed_token<T>(
&self,
token: &UntrustedToken<'_>,
verifying_key: &Self::VerifyingKey,
) -> Result<SignedToken<Self, T>, ValidationError>where
T: DeserializeOwned,
👎Deprecated: Use .validator().validate_for_signed_token()
for added flexibility
fn validate_for_signed_token<T>(
&self,
token: &UntrustedToken<'_>,
verifying_key: &Self::VerifyingKey,
) -> Result<SignedToken<Self, T>, ValidationError>where
T: DeserializeOwned,
.validator().validate_for_signed_token()
for added flexibilityValidates the token integrity against the provided verifying_key
.
Unlike validate_integrity
, this method retains more
information about the original token, in particular, its signature.
Object Safety§
This trait is not object safe.