summaryrefslogtreecommitdiff
path: root/server/src/error.rs
diff options
context:
space:
mode:
authorKjetil Orbekk <kj@orbekk.com>2022-10-08 17:22:48 -0400
committerKjetil Orbekk <kj@orbekk.com>2022-10-08 17:22:48 -0400
commit30102e5da48b53806b33f04041a46bec4c3b2fa3 (patch)
treecf9fd3ce1f8c449cb4cb1b8837015c7b514b916b /server/src/error.rs
parent1cbf881835fc33859a31645f886c5d3787ed48f8 (diff)
Add token refresh and persist sessions in the db
Diffstat (limited to 'server/src/error.rs')
-rw-r--r--server/src/error.rs28
1 files changed, 24 insertions, 4 deletions
diff --git a/server/src/error.rs b/server/src/error.rs
index 439e81b..1a45e96 100644
--- a/server/src/error.rs
+++ b/server/src/error.rs
@@ -1,5 +1,9 @@
use axum::{http::StatusCode, response::IntoResponse};
-use openidconnect::{core::CoreErrorResponseType, StandardErrorResponse, ClaimsVerificationError};
+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>,
@@ -11,18 +15,34 @@ pub enum BridgeError {
#[error("Invalid request: {0}")]
InvalidRequest(String),
- #[error("Backend request failed")]
- Backend(#[from] RequestTokenError),
+ #[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),
}
impl IntoResponse for BridgeError {
fn into_response(self) -> axum::response::Response {
+ error!("Error occurred: {self:?}");
(StatusCode::INTERNAL_SERVER_ERROR, format!("Error: {self}")).into_response()
}
}