Browse Source

fix: 修复oidc认证不区分大小写 (#8267)

Co-authored-by: feng626 <1304903146@qq.com>
pull/8268/head
fit2bot 3 years ago committed by GitHub
parent
commit
c8d7c7c56f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      apps/authentication/backends/oidc/backends.py

7
apps/authentication/backends/oidc/backends.py

@ -281,6 +281,11 @@ class OIDCAuthPasswordBackend(OIDCBaseBackend):
try:
claims_response.raise_for_status()
claims = claims_response.json()
preferred_username = claims.get('preferred_username')
if preferred_username and \
preferred_username.lower() == username.lower() and \
preferred_username != username:
return
except Exception as e:
error = "Json claims response error, claims response " \
"content is: {}, error is: {}".format(claims_response.content, str(e))
@ -309,5 +314,3 @@ class OIDCAuthPasswordBackend(OIDCBaseBackend):
openid_user_login_failed.send(
sender=self.__class__, request=request, username=username, reason="User is invalid"
)
return None

Loading…
Cancel
Save