Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix re-usage of SSO-based accounts for LDAP login #7407

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions seahub/base/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@

UNUSABLE_PASSWORD = '!' # This will never be a valid hash

SSO_LDAP_USE_SAME_UID = getattr(settings, 'SSO_LDAP_USE_SAME_UID', False)


def default_ldap_role_mapping(role):
return role
Expand Down Expand Up @@ -964,6 +966,8 @@ def authenticate(self, ldap_user=None, password=None):
# search user from ldap server
try:
auth_user = SocialAuthUser.objects.filter(username=ldap_user, provider=LDAP_PROVIDER).first()
if not auth_user and SSO_LDAP_USE_SAME_UID:
auth_user = SocialAuthUser.objects.filter(username=ldap_user).first()
if auth_user:
login_attr = auth_user.uid
else:
Expand All @@ -977,6 +981,8 @@ def authenticate(self, ldap_user=None, password=None):
except Exception as e:
if ENABLE_MULTI_LDAP:
auth_user = SocialAuthUser.objects.filter(username=ldap_user, provider=MULTI_LDAP_1_PROVIDER).first()
if not auth_user and SSO_LDAP_USE_SAME_UID:
auth_user = SocialAuthUser.objects.filter(username=ldap_user).first()
if auth_user:
login_attr = auth_user.uid
else:
Expand Down