BLOG-85 Implement OIDC authentication #93
@ -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,
|
||||||
|
@ -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
|
||||||
|
@ -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()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user