BLOG-85 Implement OIDC authentication #93

Merged
squid merged 8 commits from BLOG-85_oidc_login into main 2025-07-30 03:46:50 +08:00
3 changed files with 6 additions and 4 deletions
Showing only changes of commit 7a153f0f86 - Show all commits

View File

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

View File

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

View File

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