From 9cd163c99db315190ca2da9e985882606391fb32 Mon Sep 17 00:00:00 2001 From: Bai Date: Fri, 6 Dec 2024 15:36:54 +0800 Subject: [PATCH] fix: when oidc enabled and use_state user login raise 400 --- apps/authentication/backends/oidc/backends.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/authentication/backends/oidc/backends.py b/apps/authentication/backends/oidc/backends.py index f29bf95e5..ce384897f 100644 --- a/apps/authentication/backends/oidc/backends.py +++ b/apps/authentication/backends/oidc/backends.py @@ -107,7 +107,7 @@ class OIDCAuthCodeBackend(OIDCBaseBackend): # parameters because we won't be able to get a valid token for the user in that case. if (state is None and settings.AUTH_OPENID_USE_STATE) or code is None: logger.debug(log_prompt.format('Authorization code or state value is missing')) - raise SuspiciousOperation('Authorization code or state value is missing') + return # Prepares the token payload that will be used to request an authentication token to the # token endpoint of the OIDC provider. @@ -165,7 +165,7 @@ class OIDCAuthCodeBackend(OIDCBaseBackend): error = "Json token response error, token response " \ "content is: {}, error is: {}".format(token_response.content, str(e)) logger.debug(log_prompt.format(error)) - raise ParseError(error) + return # Validates the token. logger.debug(log_prompt.format('Validate ID Token')) @@ -206,7 +206,7 @@ class OIDCAuthCodeBackend(OIDCBaseBackend): error = "Json claims response error, claims response " \ "content is: {}, error is: {}".format(claims_response.content, str(e)) logger.debug(log_prompt.format(error)) - raise ParseError(error) + return logger.debug(log_prompt.format('Get or create user from claims')) user, created = self.get_or_create_user_from_claims(request, claims)