objectstore_server/auth/
error.rs

1use thiserror::Error;
2
3/// Error type for different authorization failure scenarios.
4#[derive(Error, Debug, PartialEq)]
5pub enum AuthError {
6    /// Indicates failure to initialize the auth system (e.g. a configured key is malformed).
7    #[error("failed to initialize auth system: {0}")]
8    InitFailure(String),
9
10    /// Indicates that something about the request prevented authorization verification from
11    /// happening properly.
12    #[error("bad request: {0}")]
13    BadRequest(&'static str),
14
15    /// Indicates that something about Objectstore prevented authorization verification from
16    /// happening properly.
17    #[error("internal error: {0}")]
18    InternalError(String),
19
20    /// Indicates that the provided authorization token is invalid (e.g. expired or malformed).
21    #[error("failed to decode token: {0}")]
22    ValidationFailure(#[from] jsonwebtoken::errors::Error),
23
24    /// Indicates that an otherwise-valid token was unable to be verified with configured keys.
25    #[error("failed to verify token")]
26    VerificationFailure,
27
28    /// Indicates that the requested operation is not authorized and auth enforcement is enabled.
29    #[error("operation not allowed")]
30    NotPermitted,
31}