1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
use axum::{http::StatusCode, response::IntoResponse};
use openidconnect::{core::CoreErrorResponseType, ClaimsVerificationError, StandardErrorResponse};
use tracing::error;
type UserInfoError = openidconnect::UserInfoError<openidconnect::reqwest::Error<reqwest::Error>>;
type RequestTokenError = openidconnect::RequestTokenError<
openidconnect::reqwest::Error<reqwest::Error>,
StandardErrorResponse<CoreErrorResponseType>,
>;
#[derive(thiserror::Error, Debug)]
pub enum BridgeError {
#[error("Invalid request: {0}")]
InvalidRequest(String),
#[error("Requesting token failed")]
OpenidRequestTokenError(#[from] RequestTokenError),
#[error("Requesting user info failed")]
OpenidUserInfoError(#[from] UserInfoError),
#[error("Failed to configure OpenId request")]
OpenIdConfigurationError(#[from] openidconnect::ConfigurationError),
#[error("Unexpected authorization error")]
UnexpectedInvalidAuthorization(#[from] ClaimsVerificationError),
#[error("Authentication error")]
SigningFailed(#[from] openidconnect::SigningError),
#[error("Database error")]
SqlxError(#[from] sqlx::Error),
#[error("Uuid parse failed")]
UuidError(#[from] uuid::Error),
#[error("Internal server error: {0}")]
Internal(String),
#[error("Duration out of range")]
DurationOutOfRange(#[from] time::OutOfRangeError),
}
impl IntoResponse for BridgeError {
fn into_response(self) -> axum::response::Response {
error!("Error occurred: {self:?}");
(StatusCode::INTERNAL_SERVER_ERROR, format!("Error: {self}")).into_response()
}
}
|