diff --git a/common/djangoapps/third_party_auth/settings.py b/common/djangoapps/third_party_auth/settings.py index a97f0f0e0d08..946865a43d6c 100644 --- a/common/djangoapps/third_party_auth/settings.py +++ b/common/djangoapps/third_party_auth/settings.py @@ -9,7 +9,7 @@ a) loads this module. b) calls apply_settings(), passing in the Django settings """ - +from django.conf import settings from openedx.features.enterprise_support.api import insert_enterprise_pipeline_elements _FIELDS_STORED_IN_SESSION = ['auth_entry', 'next'] @@ -41,6 +41,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 = _SOCIAL_AUTH_AZUREAD_OAUTH2_AUTH_EXTRA_ARGUMENTS + # 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 = [ diff --git a/common/djangoapps/third_party_auth/tests/test_settings.py b/common/djangoapps/third_party_auth/tests/test_settings.py index b08472bff0f9..8245ee7e4e3c 100644 --- a/common/djangoapps/third_party_auth/tests/test_settings.py +++ b/common/djangoapps/third_party_auth/tests/test_settings.py @@ -56,3 +56,9 @@ def test_apply_settings_turns_off_raising_social_exceptions(self): # bad in prod. settings.apply_settings(self.settings) self.assertFalse(self.settings.SOCIAL_AUTH_RAISE_EXCEPTIONS) + + def test_apply_settings_avoids_default_username_check(self): + # Avoid the default username check where non-ascii characters are not + # allowed + settings.apply_settings(self.settings) + self.assertFalse(self.settings.SOCIAL_AUTH_CLEAN_USERNAMES)