pub enum JwtError {
MissingToken,
InvalidHeader,
MalformedToken,
DeserializationFailed,
InvalidSignature,
Expired,
NotYetValid,
InvalidIssuer,
InvalidAudience,
AlgorithmMismatch,
SigningFailed,
SerializationFailed,
}Expand description
Typed JWT error enum. Stored as modo::Error source via chain().
Use error.source_as::<JwtError>() before the response pipeline
or error.error_code() after IntoResponse to identify the failure.
§Error identity pattern
use modo::auth::session::jwt::JwtError;
let err = modo::Error::unauthorized("unauthorized")
.chain(JwtError::Expired)
.with_code(JwtError::Expired.code());
// Before IntoResponse:
assert_eq!(err.source_as::<JwtError>(), Some(&JwtError::Expired));
// After IntoResponse (in error handler):
assert_eq!(err.error_code(), Some("jwt:expired"));Variants§
MissingToken
No token was found by any configured TokenSource.
InvalidHeader
The token header could not be decoded or parsed.
MalformedToken
The token does not have the expected three-part structure.
DeserializationFailed
The token payload could not be deserialized into the target claims type.
InvalidSignature
The token signature does not match the signing key.
Expired
The token has expired (exp is in the past, beyond leeway).
NotYetValid
The token is not yet valid (nbf is in the future, beyond leeway).
InvalidIssuer
The iss claim does not match the required issuer.
InvalidAudience
The aud claim does not match the required audience.
AlgorithmMismatch
The token header specifies an algorithm that differs from the verifier’s algorithm.
SigningFailed
The HMAC signing operation failed.
SerializationFailed
The claims could not be serialized to JSON.
Implementations§
Trait Implementations§
Source§impl Error for JwtError
impl Error for JwtError
1.30.0 · 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()
impl Copy for JwtError
impl Eq for JwtError
impl StructuralPartialEq for JwtError
Auto Trait Implementations§
impl Freeze for JwtError
impl RefUnwindSafe for JwtError
impl Send for JwtError
impl Sync for JwtError
impl Unpin for JwtError
impl UnsafeUnpin for JwtError
impl UnwindSafe for JwtError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.