jsonwebtoken/src/errors.rs

69 lines
2.4 KiB
Rust
Raw Normal View History

use base64;
use serde_json;
2017-02-22 02:45:28 -05:00
use ring;
2015-10-31 11:37:15 -04:00
error_chain! {
errors {
2017-02-22 02:45:28 -05:00
/// When a token doesn't have a valid token shape
InvalidToken {
description("invalid token")
display("Invalid token")
2015-10-31 11:37:15 -04:00
}
2017-02-22 02:45:28 -05:00
/// When the signature doesn't match
InvalidSignature {
description("invalid signature")
display("Invalid signature")
}
2017-02-22 02:45:28 -05:00
/// When the algorithm in the header doesn't match the one passed to `decode`
WrongAlgorithmHeader {
2017-02-22 02:45:28 -05:00
description("wrong algorithm header")
display("Wrong Algorithm Header")
}
2017-02-22 02:45:28 -05:00
/// When the secret given is not a valid RSA key
InvalidKey {
description("invalid key")
display("Invalid Key")
}
2017-04-11 01:41:44 -04:00
// Validation error
2017-02-22 02:45:28 -05:00
/// When a tokens `exp` claim indicates that it has expired
ExpiredSignature {
description("expired signature")
display("Expired Signature")
}
/// When a tokens `iss` claim does not match the expected issuer
InvalidIssuer {
description("invalid issuer")
display("Invalid Issuer")
}
/// When a tokens `aud` claim does not match one of the expected audience values
InvalidAudience {
description("invalid audience")
display("Invalid Audience")
}
2017-04-11 01:41:44 -04:00
/// When a tokens `aud` claim does not match one of the expected audience values
InvalidSubject {
description("invalid subject")
display("Invalid Subject")
}
2017-02-22 02:45:28 -05:00
/// When a tokens `iat` claim is in the future
InvalidIssuedAt {
description("invalid issued at")
display("Invalid Issued At")
}
/// When a tokens nbf claim represents a time in the future
ImmatureSignature {
description("immature signature")
display("Immature Signature")
}
}
foreign_links {
2017-04-12 21:08:07 -04:00
Unspecified(ring::error::Unspecified) #[doc = "An error happened while signing/verifying a token with RSA"];
Base64(base64::Base64Error) #[doc = "An error happened while decoding some base64 text"];
Json(serde_json::Error) #[doc = "An error happened while serializing/deserializing JSON"];
Utf8(::std::string::FromUtf8Error) #[doc = "An error happened while trying to convert the result of base64 decoding to a String"];
}
}