BLOG-85 feat: add InvalidState error to AuthError and update error handling in OIDC callback
All checks were successful
PR Title Check / pr-title-check (pull_request) Successful in 13s
Frontend CI / build (push) Successful in 1m8s

This commit is contained in:
SquidSpirit 2025-07-30 03:43:24 +08:00
parent 161ef5327a
commit 7a153f0f86
3 changed files with 6 additions and 4 deletions

View File

@ -1,6 +1,7 @@
#[derive(Debug, PartialEq)]
pub enum AuthError {
OidcError(String),
InvalidState,
InvalidNonce,
InvalidAuthCode,
InvalidIdToken,

View File

@ -38,7 +38,7 @@ impl ExchangeAuthCodeUseCase for ExchangeAuthCodeUseCaseImpl {
expected_nonce: &str,
) -> Result<User, AuthError> {
if received_state != expected_state {
return Err(AuthError::InvalidNonce);
return Err(AuthError::InvalidState);
}
self.auth_repository

View File

@ -80,9 +80,10 @@ async fn oidc_callback_handler(
.finish()
}
Err(e) => match e {
AuthError::InvalidAuthCode | AuthError::InvalidIdToken | AuthError::InvalidNonce => {
HttpResponse::BadRequest().finish()
}
AuthError::InvalidAuthCode
| AuthError::InvalidIdToken
| AuthError::InvalidNonce
| AuthError::InvalidState => HttpResponse::BadRequest().finish(),
_ => {
log::error!("{e:?}");
HttpResponse::InternalServerError().finish()