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)]
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()