pub enum JoseError {
Crypto(Error),
InvalidToken(String),
InvalidHeader(String),
InvalidClaims(String),
UnsupportedAlgorithm(String),
Key(String),
Expired,
NotYetValid,
InvalidIssuer,
InvalidAudience,
Json(Error),
Base64(String),
}Expand description
Errors produced by JOSE operations.
Variants§
Crypto(Error)
A cryptographic backend operation failed.
InvalidToken(String)
A serialized JOSE token is malformed or fails structural validation.
InvalidHeader(String)
A JOSE protected header is malformed or violates configured policy.
InvalidClaims(String)
JWT claims are malformed or violate configured validation policy.
UnsupportedAlgorithm(String)
The requested or encoded JOSE algorithm is unsupported.
Key(String)
Key material is malformed, incomplete, or incompatible with an operation.
Expired
JWT validation found that the token has expired.
NotYetValid
JWT validation found that the token is not valid yet.
InvalidIssuer
The JWT issuer does not match the configured issuer.
InvalidAudience
The JWT audience does not contain the configured audience.
Json(Error)
JSON serialization or deserialization failed.
Base64(String)
Base64url decoding failed.
Implementations§
Source§impl JoseError
impl JoseError
Sourcepub fn category(&self) -> ErrorCategory
pub fn category(&self) -> ErrorCategory
Classify this error.
Coarse by design. Note that JoseError::InvalidHeader and
JoseError::InvalidClaims land in
ErrorCategory::InvalidStructure even when the message describes a policy
refusal (e.g. a required kid): the variants carry structure and policy
cases, and claiming a finer split than the variants express would make the
category a second, contradicting source of truth. Use the specific variants
when the distinction matters.
Sourcepub fn is_authentication_failure(&self) -> bool
pub fn is_authentication_failure(&self) -> bool
The merged question: “did a verification fail?”.
True for this crate’s own “signature did not verify” verdict and for backend cryptographic failures. On a path that was verifying or decrypting, that union is exactly “the credential did not authenticate”, and it is exposed as one answer because splitting it (was the tag wrong, or was the structure refused on the way to the tag?) is a signal an attacker can request.
Call it only on errors from a verify/decrypt path: on a key-import or encryption
path a JoseError::Crypto means something else entirely, and this function
cannot tell which path produced the error.
Trait Implementations§
Source§impl Error for JoseError
impl Error for JoseError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()