1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-04-27 11:01:14 +00:00

Update backends.py (#7604)

* Update backends.py

* Update backends.py
This commit is contained in:
Ranjiwei 2025-03-14 09:40:19 +08:00 committed by GitHub
parent c6bf21f2ab
commit feab625130
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,6 +12,8 @@ from registration.models import (
logger = logging.getLogger(__name__)
SHIBBOLETH_PROVIDER_IDENTIFIER = getattr(settings, 'SHIBBOLETH_PROVIDER_IDENTIFIER', 'shibboleth')
LDAP_PROVIDER = getattr(settings, 'LDAP_PROVIDER', 'ldap')
SSO_LDAP_USE_SAME_UID = getattr(settings, 'SSO_LDAP_USE_SAME_UID', False)
class ShibbolethRemoteUserBackend(RemoteUserBackend):
@ -52,6 +54,9 @@ class ShibbolethRemoteUserBackend(RemoteUserBackend):
remote_user = self.clean_username(remote_user)
shib_user = SocialAuthUser.objects.get_by_provider_and_uid(SHIBBOLETH_PROVIDER_IDENTIFIER, remote_user)
if not shib_user and SSO_LDAP_USE_SAME_UID:
shib_user = SocialAuthUser.objects.get_by_provider_and_uid(LDAP_PROVIDER, remote_user)
if shib_user:
try:
user = User.objects.get(email=shib_user.username)