fix: fixed redirect_uri with handler_uri in session

Previously the redirect_uri was the uri of the handler that needed
authentication.
Now one fixed redirect_uri for the entire application is used that will
redirect the user to the correct handler after successful
authentication.
This commit should fix: #28, #27, #26, #21
This commit is contained in:
Paul Zinselmeyer 2025-04-18 12:30:29 +02:00
parent 58369449cf
commit 19adcbabd2
Signed by: pfzetto
GPG key ID: B471A1AF06C895FD
6 changed files with 246 additions and 239 deletions

View file

@ -72,6 +72,45 @@ pub enum MiddlewareError {
AuthMiddlewareNotFound,
}
#[derive(Debug, Error)]
pub enum HandlerError {
#[error("the redirect handler got accessed without a valid session")]
RedirectedWithoutSession,
#[error("csrf token invalid")]
CsrfTokenInvalid,
#[error("id token missing")]
IdTokenMissing,
#[error("access token hash invalid")]
AccessTokenHashInvalid,
#[error("signing: {0:?}")]
Signing(#[from] openidconnect::SigningError),
#[error("signature verification: {0:?}")]
Signature(#[from] openidconnect::SignatureVerificationError),
#[error("session error: {0:?}")]
Session(#[from] tower_sessions::session::Error),
#[error("configuration: {0:?}")]
Configuration(#[from] openidconnect::ConfigurationError),
#[error("request token: {0:?}")]
RequestToken(
#[from]
openidconnect::RequestTokenError<
openidconnect::HttpClientError<openidconnect::reqwest::Error>,
StandardErrorResponse<CoreErrorResponseType>,
>,
),
#[error("claims verification: {0:?}")]
ClaimsVerification(#[from] openidconnect::ClaimsVerificationError),
}
#[derive(Debug, Error)]
pub enum Error {
#[error("url parsing: {0:?}")]
@ -93,6 +132,9 @@ pub enum Error {
#[error("extractor: {0:?}")]
Middleware(#[from] MiddlewareError),
#[error("handler: {0:?}")]
Handler(#[from] HandlerError),
}
impl IntoResponse for ExtractorError {
@ -124,3 +166,11 @@ impl IntoResponse for MiddlewareError {
}
}
}
impl IntoResponse for HandlerError {
fn into_response(self) -> axum_core::response::Response {
match self {
_ => (StatusCode::INTERNAL_SERVER_ERROR, "internal server error").into_response(),
}
}
}