hue icon indicating copy to clipboard operation
hue copied to clipboard

[auth] Display login form when OIDC auth is enabled along with other auth backends

Open idzikovsky opened this issue 7 months ago • 7 comments

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

idzikovsky avatar May 30 '25 18:05 idzikovsky

⚠️ No test files modified. Please ensure that changes are properly tested. ⚠️

github-actions[bot] avatar May 30 '25 18:05 github-actions[bot]

Python Code Coverage

Python Coverage Report •
FileStmtsMissCoverMissing
TOTAL541852707850% 
report-only-changed-files is enabled. No files were changed during this commit :)

Pytest Report

Tests Skipped Failures Errors Time
1186 106 :zzz: 0 :x: 0 :fire: 5m 55s :stopwatch:

github-actions[bot] avatar May 30 '25 18:05 github-actions[bot]

UI Coverage Report

Lines Statements Branches Functions
Coverage: 32%
39.15% (30527/77959) 31.01% (14247/45936) 23.89% (2130/8915)

github-actions[bot] avatar Jun 02 '25 16:06 github-actions[bot]

Python Code Coverage

Python Coverage Report •
FileStmtsMissCoverMissing
TOTAL541852707850% 
report-only-changed-files is enabled. No files were changed during this commit :)

Pytest Report

Tests Skipped Failures Errors Time
1186 106 :zzz: 0 :x: 0 :fire: 6m 1s :stopwatch:

github-actions[bot] avatar Jun 02 '25 16:06 github-actions[bot]

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

idzikovsky avatar Jun 04 '25 19:06 idzikovsky

Python Code Coverage

Python Coverage Report •
FileStmtsMissCoverMissing
TOTAL541852707850% 
report-only-changed-files is enabled. No files were changed during this commit :)

Pytest Report

Tests Skipped Failures Errors Time
1186 106 :zzz: 0 :x: 0 :fire: 5m 58s :stopwatch:

github-actions[bot] avatar Jun 04 '25 19:06 github-actions[bot]

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)

idzikovsky avatar Jun 04 '25 20:06 idzikovsky

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.

github-actions[bot] avatar Jul 26 '25 02:07 github-actions[bot]

Hey 🙁

idzikovsky avatar Aug 05 '25 09:08 idzikovsky