BLOG-85 Implement OIDC authentication #93
@ -1,6 +1,7 @@
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum AuthError {
|
||||
OidcError(String),
|
||||
InvalidState,
|
||||
InvalidNonce,
|
||||
InvalidAuthCode,
|
||||
InvalidIdToken,
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user