Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

fix(users): add bad request for openidconnect (#9244)

Rachit Naithani09d475b423c0
diff --git a/crates/router/src/services/openidconnect.rs b/crates/router/src/services/openidconnect.rs
index ca20b021a5..69b890d657 100644
--- a/crates/router/src/services/openidconnect.rs
+++ b/crates/router/src/services/openidconnect.rs
@@ -76,7 +76,14 @@ pub async fn get_user_email_from_oidc_provider(
.exchange_code(oidc::AuthorizationCode::new(authorization_code.expose()))
.request_async(|req| get_oidc_reqwest_client(state, req))
.await
- .change_context(UserErrors::InternalServerError)
+ .map_err(|e| match e {
+ oidc::RequestTokenError::ServerResponse(resp)
+ if resp.error() == &oidc_core::CoreErrorResponseType::InvalidGrant =>
+ {
+ UserErrors::SSOFailed
+ }
+ _ => UserErrors::InternalServerError,
+ })
.attach_printable("Failed to exchange code and fetch oidc token")?;
// Fetch id token from response