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

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

@ -281,6 +281,11 @@ class OIDCAuthPasswordBackend(OIDCBaseBackend):
try: try:
claims_response.raise_for_status() claims_response.raise_for_status()
claims = claims_response.json() 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: except Exception as e:
error = "Json claims response error, claims response " \ error = "Json claims response error, claims response " \
"content is: {}, error is: {}".format(claims_response.content, str(e)) "content is: {}, error is: {}".format(claims_response.content, str(e))
@ -309,5 +314,3 @@ class OIDCAuthPasswordBackend(OIDCBaseBackend):
openid_user_login_failed.send( openid_user_login_failed.send(
sender=self.__class__, request=request, username=username, reason="User is invalid" sender=self.__class__, request=request, username=username, reason="User is invalid"
) )
return None

Loading…
Cancel
Save