Merge pull request #20900 from open-craft/pooja/fix-username-hints-with-SSO
SE-1199 Campus.il Fix unicode username hints with SSO
This commit is contained in:
@@ -11,7 +11,7 @@ If true, it:
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.conf import settings
|
||||
from openedx.features.enterprise_support.api import insert_enterprise_pipeline_elements
|
||||
|
||||
|
||||
@@ -42,6 +42,9 @@ def apply_settings(django_settings):
|
||||
# Adding extra key value pair in the url query string for microsoft as per request
|
||||
django_settings.SOCIAL_AUTH_AZUREAD_OAUTH2_AUTH_EXTRA_ARGUMENTS = {'msafed': 0}
|
||||
|
||||
# Avoid default username check to allow non-ascii characters
|
||||
django_settings.SOCIAL_AUTH_CLEAN_USERNAMES = not settings.FEATURES.get("ENABLE_UNICODE_USERNAME")
|
||||
|
||||
# Inject our customized auth pipeline. All auth backends must work with
|
||||
# this pipeline.
|
||||
django_settings.SOCIAL_AUTH_PIPELINE = [
|
||||
|
||||
@@ -4,6 +4,7 @@ from __future__ import absolute_import
|
||||
|
||||
import unittest
|
||||
|
||||
from mock import patch
|
||||
from third_party_auth import provider, settings
|
||||
from third_party_auth.tests import testutil
|
||||
|
||||
@@ -58,3 +59,12 @@ class SettingsUnitTest(testutil.TestCase):
|
||||
def test_apply_settings_turns_off_redirect_sanitization(self):
|
||||
settings.apply_settings(self.settings)
|
||||
self.assertFalse(self.settings.SOCIAL_AUTH_SANITIZE_REDIRECTS)
|
||||
|
||||
def test_apply_settings_avoids_default_username_check(self):
|
||||
# Avoid the default username check where non-ascii characters are not
|
||||
# allowed when unicode username is enabled
|
||||
settings.apply_settings(self.settings)
|
||||
self.assertTrue(self.settings.SOCIAL_AUTH_CLEAN_USERNAMES) # verify default behavior
|
||||
with patch.dict('django.conf.settings.FEATURES', {'ENABLE_UNICODE_USERNAME': True}):
|
||||
settings.apply_settings(self.settings)
|
||||
self.assertFalse(self.settings.SOCIAL_AUTH_CLEAN_USERNAMES)
|
||||
|
||||
Reference in New Issue
Block a user