refactor: move third_party_auth settings from app startup to static config #37965
+178
−182
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This refactoring moves all third-party authentication settings from
runtime configuration during AppConfig.ready() to static definitions
in lms/envs/common.py.
The problem was first reported here: https://discuss.openedx.org/t/third-party-auth-customization/16929/6
Problem
The third_party_auth app used an
apply_settings()function calledduring Django's app initialization to modify Django settings. This
pattern caused issues:
be finalized, making debugging difficult
files because apply_settings() would overwrite their values
Why the ENABLE_THIRD_PARTY_AUTH conditional was removed
The settings are now defined unconditionally because:
in AUTHENTICATION_BACKENDS - they have no effect
authentication backends and exposure of auth URLs
exist but are no-ops when their feature isn't active
Enterprise pipeline integration
The enterprise pipeline step (handle_enterprise_logistration) is
included statically in SOCIAL_AUTH_PIPELINE rather than being inserted
dynamically. This step handles its own runtime checks and returns early
if enterprise is not configured, making it safe to include always. This
avoids complexity with Derived() functions that would need to import
Django models at settings load time (before apps are ready).
Operator impact
Operators can now properly override any of these settings in their YAML
configuration files, including SOCIAL_AUTH_PIPELINE for custom flows.
Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com