pub enum JwtError {
Show 28 variants
MissingSecretKey,
Forbidden,
MissingAuthenticator,
MissingLoginValues,
FailedAuthentication,
FailedTokenCreation,
ExpiredToken,
EmptyAuthHeader,
MissingExpField,
WrongFormatOfExp,
InvalidAuthHeader,
EmptyQueryToken,
EmptyCookieToken,
EmptyParamToken,
InvalidSigningAlgorithm,
NoPrivKeyFile,
NoPubKeyFile,
InvalidPrivKey,
InvalidPubKey,
MissingRefreshToken,
InvalidRefreshToken,
RefreshTokenNotFound,
RefreshTokenExpired,
TokenEmpty,
ExpiryInPast,
TokenParsing(String),
TokenExtraction(String),
Internal(String),
}Expand description
Unified error type for the JWT middleware.
Each variant maps to a specific HTTP status code via the
actix_web::ResponseError implementation.
§Examples
use actix_jwt::JwtError;
let err = JwtError::ExpiredToken;
assert_eq!(err.to_string(), "token is expired");Variants that carry a message reproduce it verbatim:
use actix_jwt::JwtError;
let err = JwtError::TokenParsing("invalid signature".into());
assert_eq!(err.to_string(), "invalid signature");
assert!(err.is_token_parsing());Variants§
MissingSecretKey
HMAC secret key was not provided.
Forbidden
The authorizer callback rejected the request.
MissingAuthenticator
No authenticator callback was configured.
MissingLoginValues
The request body could not be parsed into login credentials.
FailedAuthentication
The authenticator callback returned an error.
FailedTokenCreation
JWT signing or encoding failed.
ExpiredToken
The access token’s exp claim is in the past.
EmptyAuthHeader
The Authorization header is present but empty.
MissingExpField
The exp claim is missing from the token.
WrongFormatOfExp
The exp claim is not a numeric value.
InvalidAuthHeader
The Authorization header does not match the expected format.
EmptyQueryToken
The query-string token source was empty.
EmptyCookieToken
The cookie token source was empty.
EmptyParamToken
The path-parameter token source was empty.
InvalidSigningAlgorithm
The configured signing algorithm is not supported.
NoPrivKeyFile
The private key file could not be read.
NoPubKeyFile
The public key file could not be read.
InvalidPrivKey
The private key could not be parsed.
InvalidPubKey
The public key could not be parsed.
MissingRefreshToken
No refresh_token was found in the request.
InvalidRefreshToken
The refresh token failed validation.
RefreshTokenNotFound
The refresh token was not found in the store.
RefreshTokenExpired
The refresh token has expired.
TokenEmpty
An empty token string was passed to a store method.
ExpiryInPast
The supplied expiry timestamp is in the past.
TokenParsing(String)
A token parsing / validation error with a free-form message.
TokenExtraction(String)
A token extraction error with a free-form message.
Internal(String)
An internal / infrastructure error with a free-form message.
Implementations§
Source§impl JwtError
impl JwtError
Sourcepub fn is_token_parsing(&self) -> bool
pub fn is_token_parsing(&self) -> bool
Returns true for the TokenParsing variant.
§Examples
use actix_jwt::JwtError;
assert!(JwtError::TokenParsing("bad".into()).is_token_parsing());
assert!(!JwtError::Forbidden.is_token_parsing());Sourcepub fn is_token_extraction(&self) -> bool
pub fn is_token_extraction(&self) -> bool
Returns true for the TokenExtraction variant.
§Examples
use actix_jwt::JwtError;
assert!(JwtError::TokenExtraction("empty".into()).is_token_extraction());
assert!(!JwtError::ExpiredToken.is_token_extraction());Sourcepub fn is_forbidden(&self) -> bool
pub fn is_forbidden(&self) -> bool
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()