Commit a87844f
refactor: move third_party_auth settings from app startup to static config
This refactoring moves all third-party authentication settings from
runtime configuration during AppConfig.ready() to static definitions
in lms/envs/common.py.
## Problem
The third_party_auth app used an `apply_settings()` function called
during Django's app initialization to modify Django settings. This
pattern caused issues:
1. Settings were modified after Django initialization when they should
be finalized, making debugging difficult
2. Operators couldn't override these settings in their YAML config
files because apply_settings() would overwrite their values
## Why the ENABLE_THIRD_PARTY_AUTH conditional was removed
The settings are now defined unconditionally because:
1. These settings are inert when social auth backends aren't configured
in AUTHENTICATION_BACKENDS - they have no effect
2. ENABLE_THIRD_PARTY_AUTH still controls what matters: registration of
authentication backends and exposure of auth URLs
3. This follows standard Django patterns where middleware and settings
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 <[email protected]>1 parent 6cb2ea3 commit a87844f
File tree
4 files changed
+127
-176
lines changed- common/djangoapps/third_party_auth
- tests
- lms/envs
4 files changed
+127
-176
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
| |||
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 13 | + | |
This file was deleted.
Lines changed: 56 additions & 55 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
6 | 7 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | 8 | | |
24 | 9 | | |
25 | | - | |
26 | | - | |
| 10 | + | |
| 11 | + | |
27 | 12 | | |
28 | | - | |
29 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
30 | 16 | | |
31 | | - | |
32 | | - | |
33 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
34 | 20 | | |
35 | | - | |
36 | | - | |
37 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
38 | 25 | | |
39 | | - | |
40 | | - | |
41 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
42 | 29 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
48 | 45 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
54 | 55 | | |
55 | | - | |
56 | | - | |
57 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
58 | 62 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
303 | 366 | | |
304 | 367 | | |
305 | 368 | | |
| |||
799 | 862 | | |
800 | 863 | | |
801 | 864 | | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
802 | 869 | | |
803 | 870 | | |
804 | 871 | | |
| |||
1211 | 1278 | | |
1212 | 1279 | | |
1213 | 1280 | | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
1214 | 1284 | | |
1215 | 1285 | | |
1216 | 1286 | | |
| |||
0 commit comments