summaryrefslogtreecommitdiff
path: root/server/src/error.rs
diff options
context:
space:
mode:
authorKjetil Orbekk <kj@orbekk.com>2022-10-13 08:12:59 -0400
committerKjetil Orbekk <kj@orbekk.com>2022-10-13 08:12:59 -0400
commitaccb9032b9abe595020a27dd2f7b666cb7028f67 (patch)
tree4c92937ad368e93e9bb9ddf9a0ebb31e8288c04b /server/src/error.rs
parent8b5d16152ffb7d55811a7a558f67620a94e4cbf0 (diff)
Add AuthenticatedSession request extractor
Diffstat (limited to 'server/src/error.rs')
-rw-r--r--server/src/error.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/server/src/error.rs b/server/src/error.rs
index cea23e7..aef2687 100644
--- a/server/src/error.rs
+++ b/server/src/error.rs
@@ -1,4 +1,4 @@
-use axum::{http::StatusCode, response::IntoResponse};
+use axum::{http::{StatusCode, self}, response::IntoResponse};
use openidconnect::{core::CoreErrorResponseType, ClaimsVerificationError, StandardErrorResponse};
use tracing::error;
@@ -26,6 +26,9 @@ pub enum BridgeError {
#[error("Unexpected authorization error")]
UnexpectedInvalidAuthorization(#[from] ClaimsVerificationError),
+ #[error("User is not logged in")]
+ NotLoggedIn,
+
#[error("Authentication error")]
SigningFailed(#[from] openidconnect::SigningError),
@@ -42,9 +45,15 @@ pub enum BridgeError {
DurationOutOfRange(#[from] time::OutOfRangeError),
}
+impl BridgeError {
+ pub fn as_rejection(&self) -> (http::StatusCode, String) {
+ (StatusCode::INTERNAL_SERVER_ERROR, format!("Error: {self}"))
+ }
+}
+
impl IntoResponse for BridgeError {
fn into_response(self) -> axum::response::Response {
error!("Error occurred: {self:?}");
- (StatusCode::INTERNAL_SERVER_ERROR, format!("Error: {self}")).into_response()
+ self.as_rejection().into_response()
}
}