diff options
author | Kjetil Orbekk <kj@orbekk.com> | 2022-10-08 10:30:15 -0400 |
---|---|---|
committer | Kjetil Orbekk <kj@orbekk.com> | 2022-10-08 10:30:15 -0400 |
commit | 1cbf881835fc33859a31645f886c5d3787ed48f8 (patch) | |
tree | eb7a8ac803e33283ea0efffa015c8bd96ca40c29 /server/src/error.rs | |
parent | b727db0d64f4250742b0ebaac0149c1224a0d040 (diff) |
Add access token validation
Diffstat (limited to 'server/src/error.rs')
-rw-r--r-- | server/src/error.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/server/src/error.rs b/server/src/error.rs new file mode 100644 index 0000000..439e81b --- /dev/null +++ b/server/src/error.rs @@ -0,0 +1,28 @@ +use axum::{http::StatusCode, response::IntoResponse}; +use openidconnect::{core::CoreErrorResponseType, StandardErrorResponse, ClaimsVerificationError}; + +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("Backend request failed")] + Backend(#[from] RequestTokenError), + + #[error("Unexpected authorization error")] + UnexpectedInvalidAuthorization(#[from] ClaimsVerificationError), + + #[error("Internal server error: {0}")] + Internal(String), +} + +impl IntoResponse for BridgeError { + fn into_response(self) -> axum::response::Response { + (StatusCode::INTERNAL_SERVER_ERROR, format!("Error: {self}")).into_response() + } +} |