Skip to main content

light_openid/
errors.rs

1use reqwest::StatusCode;
2
3#[derive(thiserror::Error, Debug)]
4pub enum OpenIdError {
5    #[error("Reqwest error: {0}")]
6    Reqwest(#[from] reqwest::Error),
7    #[error("http request failed with status: {0}")]
8    HTTPRequestFailedWithInvalidStatus(StatusCode),
9    #[error("Serde json error: {0}")]
10    SerdeJson(#[from] serde_json::Error),
11    #[error("validate id token: {0}")]
12    ValidateIdToken(Box<Self>),
13    #[error("decode jwt header: {0}")]
14    DecodeJWTHeader(#[source] jsonwebtoken::errors::Error),
15    #[error("kid is required for signature verification!")]
16    KidRequiredForSignatureVerification,
17    #[error("missing jwks in client configuration!")]
18    MissingJWKs,
19    #[error("unknown kid for signature verification: {0}")]
20    UnknownKid(String),
21    #[error("failed to decode jwk: {0}")]
22    DecodeJWK(#[source] jsonwebtoken::errors::Error),
23    #[error("failed to validate jwk: {0}")]
24    ValidateJWT(#[source] jsonwebtoken::errors::Error),
25    #[cfg(feature = "crypto-wrapper")]
26    #[error("State error: invalid IP")]
27    StateErrorInvalidIP,
28    #[cfg(feature = "crypto-wrapper")]
29    #[error("State error: expired")]
30    StateErrorExpired,
31    #[cfg(feature = "crypto-wrapper")]
32    #[error("Rkyv error: {0}")]
33    RkyvError(#[from] rkyv::rancor::Error),
34    #[cfg(feature = "crypto-wrapper")]
35    #[error("Base64 decoding error: {0}")]
36    Base64Decode(#[from] base64::DecodeError),
37    #[cfg(feature = "crypto-wrapper")]
38    #[error("Input string is smaller than nonce!")]
39    DecInputStringSmallerThanNonce,
40    #[cfg(feature = "crypto-wrapper")]
41    #[error("Failed to decrypt wrapped data!")]
42    DecryptWrappedData,
43    #[cfg(feature = "crypto-wrapper")]
44    #[error("try from slice error: {0}")]
45    TryFromSliceError(#[from] std::array::TryFromSliceError),
46}
47
48pub(crate) type Res<T = ()> = Result<T, OpenIdError>;