[auth] Display login form when OIDC auth is enabled along with other auth backends
What changes were proposed in this pull request?
Without this fix Hue skips login form when desktop.auth.backend set to desktop.auth.backend.OIDCBackend (and does not include desktop.auth.backend.AllowFirstUserDjangoBackend).
But this does not cover a lot of cases, e.g.:
[desktop]
[[auth]]
backend=desktop.auth.backend.LdapBackend,desktop.auth.backend.OIDCBackend
or:
[desktop]
[[auth]]
backend=desktop.auth.backend.AllowFirstUserDjangoBackend,desktop.auth.backend.PamBackend,desktop.auth.backend.OIDCBackend
So in my opinion it's better to skip that form only when only OIDCBackend is used (pretty much exactly like the comment on the first line of that if statement says).
How was this patch tested?
Manual
⚠️ No test files modified. Please ensure that changes are properly tested. ⚠️
Python Coverage Report •
report-only-changed-files is enabled. No files were changed during this commit :)File Stmts Miss Cover Missing TOTAL 54185 27078 50%
Pytest Report
| Tests | Skipped | Failures | Errors | Time |
|---|---|---|---|---|
| 1186 | 106 :zzz: | 0 :x: | 0 :fire: | 5m 55s :stopwatch: |
UI Coverage Report
| Lines | Statements | Branches | Functions |
|---|---|---|---|
| 39.15% (30527/77959) | 31.01% (14247/45936) | 23.89% (2130/8915) |
Python Coverage Report •
report-only-changed-files is enabled. No files were changed during this commit :)File Stmts Miss Cover Missing TOTAL 54185 27078 50%
Pytest Report
| Tests | Skipped | Failures | Errors | Time |
|---|---|---|---|---|
| 1186 | 106 :zzz: | 0 :x: | 0 :fire: | 6m 1s :stopwatch: |
I did additional testing on this and it appeared that we also need to ignore the axes.backends.AxesBackend entry added here:
https://github.com/cloudera/hue/blob/84d4002d/desktop/core/src/desktop/settings.py#L530
Python Coverage Report •
report-only-changed-files is enabled. No files were changed during this commit :)File Stmts Miss Cover Missing TOTAL 54185 27078 50%
Pytest Report
| Tests | Skipped | Failures | Errors | Time |
|---|---|---|---|---|
| 1186 | 106 :zzz: | 0 :x: | 0 :fire: | 5m 58s :stopwatch: |
Or another variant here is to remove axes backend in a separate step to make code clearer:
def only_oidc_configured():
"""Check if only the OIDC Auth Backend is enabled."""
backends = filter(lambda backend: backend != 'axes.backends.AxesBackend', AUTHENTICATION_BACKENDS) # ignore implicitly added backends
return all(backend == 'desktop.auth.backend.OIDCBackend' for backend in backends)
This PR is stale because it has been open 45 days with no activity and is not labeled "Prevent stale". Remove "stale" label or comment or this will be closed in 10 days.
Hey 🙁