mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-19 18:29:23 +00:00
SSO_LDAP_USE_SAME_UID (#6903)
This commit is contained in:
@@ -36,6 +36,8 @@ logger = logging.getLogger(__name__)
|
|||||||
SAML_PROVIDER_IDENTIFIER = getattr(settings, 'SAML_PROVIDER_IDENTIFIER', 'saml')
|
SAML_PROVIDER_IDENTIFIER = getattr(settings, 'SAML_PROVIDER_IDENTIFIER', 'saml')
|
||||||
SHIBBOLETH_AFFILIATION_ROLE_MAP = getattr(settings, 'SHIBBOLETH_AFFILIATION_ROLE_MAP', {})
|
SHIBBOLETH_AFFILIATION_ROLE_MAP = getattr(settings, 'SHIBBOLETH_AFFILIATION_ROLE_MAP', {})
|
||||||
CACHE_KEY_GROUPS = "all_groups_cache"
|
CACHE_KEY_GROUPS = "all_groups_cache"
|
||||||
|
LDAP_PROVIDER = getattr(settings, 'LDAP_PROVIDER', 'ldap')
|
||||||
|
SSO_LDAP_USE_SAME_UID = getattr(settings, 'SSO_LDAP_USE_SAME_UID', False)
|
||||||
|
|
||||||
|
|
||||||
class Saml2Backend(ModelBackend):
|
class Saml2Backend(ModelBackend):
|
||||||
@@ -58,6 +60,8 @@ class Saml2Backend(ModelBackend):
|
|||||||
name_id = name_id.text
|
name_id = name_id.text
|
||||||
|
|
||||||
saml_user = SocialAuthUser.objects.get_by_provider_and_uid(SAML_PROVIDER_IDENTIFIER, name_id)
|
saml_user = SocialAuthUser.objects.get_by_provider_and_uid(SAML_PROVIDER_IDENTIFIER, name_id)
|
||||||
|
if not saml_user and SSO_LDAP_USE_SAME_UID:
|
||||||
|
saml_user = SocialAuthUser.objects.get_by_provider_and_uid(LDAP_PROVIDER, name_id)
|
||||||
if saml_user:
|
if saml_user:
|
||||||
user = self.get_user(saml_user.username)
|
user = self.get_user(saml_user.username)
|
||||||
if not user:
|
if not user:
|
||||||
|
@@ -20,6 +20,9 @@ import seahub.settings as settings
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
LDAP_PROVIDER = getattr(settings, 'LDAP_PROVIDER', 'ldap')
|
||||||
|
SSO_LDAP_USE_SAME_UID = getattr(settings, 'SSO_LDAP_USE_SAME_UID', False)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
current_path = os.path.dirname(os.path.abspath(__file__))
|
current_path = os.path.dirname(os.path.abspath(__file__))
|
||||||
seafile_conf_dir = os.path.join(current_path, '../../../../conf')
|
seafile_conf_dir = os.path.join(current_path, '../../../../conf')
|
||||||
@@ -176,6 +179,8 @@ def oauth_callback(request):
|
|||||||
old_email = oauth_user_info.get('email', '')
|
old_email = oauth_user_info.get('email', '')
|
||||||
|
|
||||||
oauth_user = SocialAuthUser.objects.get_by_provider_and_uid(OAUTH_PROVIDER, uid)
|
oauth_user = SocialAuthUser.objects.get_by_provider_and_uid(OAUTH_PROVIDER, uid)
|
||||||
|
if not oauth_user and SSO_LDAP_USE_SAME_UID:
|
||||||
|
oauth_user = SocialAuthUser.objects.get_by_provider_and_uid(LDAP_PROVIDER, uid)
|
||||||
if oauth_user:
|
if oauth_user:
|
||||||
email = oauth_user.username
|
email = oauth_user.username
|
||||||
is_new_user = False
|
is_new_user = False
|
||||||
|
@@ -334,6 +334,8 @@ LDAP_CONTACT_EMAIL_ATTR = ''
|
|||||||
LDAP_USER_ROLE_ATTR = ''
|
LDAP_USER_ROLE_ATTR = ''
|
||||||
ACTIVATE_USER_WHEN_IMPORT = True
|
ACTIVATE_USER_WHEN_IMPORT = True
|
||||||
|
|
||||||
|
SSO_LDAP_USE_SAME_UID = False
|
||||||
|
|
||||||
# enable ldap sasl auth
|
# enable ldap sasl auth
|
||||||
ENABLE_SASL = False
|
ENABLE_SASL = False
|
||||||
SASL_MECHANISM = ''
|
SASL_MECHANISM = ''
|
||||||
|
Reference in New Issue
Block a user