1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-26 15:26:19 +00:00

Merge branch '12.0'

This commit is contained in:
Michael An
2025-03-17 16:36:44 +08:00
parent 2c57086489
commit acfc971ddd
9 changed files with 44 additions and 16 deletions

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,11 @@ 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:
SocialAuthUser.objects.add(shib_user.username, SHIBBOLETH_PROVIDER_IDENTIFIER, remote_user)
if shib_user:
try:
user = User.objects.get(email=shib_user.username)