Skip to content

Commit 07a0997

Browse files
committed
refactor: migrate THIRD_PARTY_AUTH_HINT off FEATURES-as-dict
The tpa_hint was only read via settings.FEATURES.get with an inline '' default and was never defined in a common envs file. Add an annotated flat setting (default '') to openedx/envs/common.py so the shared reader in common/djangoapps/student/helpers.py can read it directly from both LMS and CMS, and convert the test overrides.
1 parent 0dd8bef commit 07a0997

4 files changed

Lines changed: 11 additions & 5 deletions

File tree

common/djangoapps/student/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def get_next_url_for_login_page(request, include_host=False):
316316
# Append a tpa_hint query parameter, if one is configured
317317
tpa_hint = configuration_helpers.get_value(
318318
"THIRD_PARTY_AUTH_HINT",
319-
settings.FEATURES.get("THIRD_PARTY_AUTH_HINT", '')
319+
settings.THIRD_PARTY_AUTH_HINT
320320
)
321321
if tpa_hint:
322322
# Don't add tpa_hint if we're already in the TPA pipeline (prevent infinite loop),

common/djangoapps/student/tests/test_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def validate_login():
126126
next_page = get_next_url_for_login_page(req)
127127
assert next_page == expected_url
128128

129-
with override_settings(FEATURES=dict(settings.FEATURES, THIRD_PARTY_AUTH_HINT=tpa_hint)):
129+
with override_settings(THIRD_PARTY_AUTH_HINT=tpa_hint):
130130
validate_login()
131131

132132
with with_site_configuration_context(configuration=dict(THIRD_PARTY_AUTH_HINT=tpa_hint)):

openedx/core/djangoapps/user_authn/views/tests/test_logistration.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,14 +289,14 @@ def test_hinted_login_dialog_disabled(self, url_name, auth_entry):
289289
target_status_code=302
290290
)
291291

292-
@override_settings(FEATURES=dict(settings.FEATURES, THIRD_PARTY_AUTH_HINT='oa2-google-oauth2'))
292+
@override_settings(THIRD_PARTY_AUTH_HINT='oa2-google-oauth2')
293293
@ddt.data(
294294
'signin_user',
295295
'register_user',
296296
)
297297
def test_settings_tpa_hinted_login(self, url_name):
298298
"""
299-
Ensure that settings.FEATURES['THIRD_PARTY_AUTH_HINT'] can set third_party_auth_hint.
299+
Ensure that settings.THIRD_PARTY_AUTH_HINT can set third_party_auth_hint.
300300
"""
301301
params = [("next", "/courses/something/")]
302302
response = self.client.get(reverse(url_name), params, HTTP_ACCEPT="text/html")
@@ -314,7 +314,7 @@ def test_settings_tpa_hinted_login(self, url_name):
314314
response = self.client.get(reverse(url_name), params, HTTP_ACCEPT="text/html")
315315
assert response.content.decode('utf-8') not in tpa_hint
316316

317-
@override_settings(FEATURES=dict(settings.FEATURES, THIRD_PARTY_AUTH_HINT='oa2-google-oauth2'))
317+
@override_settings(THIRD_PARTY_AUTH_HINT='oa2-google-oauth2')
318318
@ddt.data(
319319
('signin_user', 'login'),
320320
('register_user', 'register'),

openedx/envs/common.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,12 @@ def add_optional_apps(optional_apps, installed_apps):
11661166
# .. toggle_tickets: https://github.com/openedx/edx-platform/pull/7315
11671167
LICENSING = False
11681168

1169+
# .. setting_name: THIRD_PARTY_AUTH_HINT
1170+
# .. setting_default: ''
1171+
# .. setting_description: Default third-party auth provider hint (tpa_hint) to append to login/registration
1172+
# redirect URLs site-wide. Usually left empty and overridden per-site via site configuration.
1173+
THIRD_PARTY_AUTH_HINT = ''
1174+
11691175
# .. toggle_name: CERTIFICATES_HTML_VIEW
11701176
# .. toggle_implementation: DjangoSetting
11711177
# .. toggle_default: False

0 commit comments

Comments
 (0)