-
Notifications
You must be signed in to change notification settings - Fork 395
[auth] Display login form when OIDC auth is enabled along with other auth backends #4153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refines when the OIDC login form is displayed by introducing a helper that detects if OIDC is the only authentication backend and updating the login URL logic accordingly.
- Add
only_oidc_configured
to check if the backends list contains only OIDC - Replace the previous backend check with
only_oidc_configured
in the login URL condition - Ensure
mozilla_django_oidc
is added toINSTALLED_APPS
when OIDC is enabled
Comments suppressed due to low confidence (2)
desktop/core/src/desktop/settings.py:597
- [nitpick] The loop variable
b
is ambiguous; consider renaming it tobackend
for better readability.
return not [b for b in AUTHENTICATION_BACKENDS if b != 'desktop.auth.backend.OIDCBackend']
desktop/core/src/desktop/settings.py:596
- Introduce unit tests for
only_oidc_configured
covering cases with single OIDC backend, multiple backends including OIDC, and no OIDC backend to ensure correct behavior.
def only_oidc_configured():
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks @idzikovsky for contributing a fix!
There are some nits from the copilot review, can you please take a look if possible and rebase your PR to latest master?
54d72a8
to
1047664
Compare
I did additional testing on this and it appeared that we also need to ignore the |
Or another variant here is to remove 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) |
What changes were proposed in this pull request?
Without this fix Hue skips login form when
desktop.auth.backend
set todesktop.auth.backend.OIDCBackend
(and does not includedesktop.auth.backend.AllowFirstUserDjangoBackend
).But this does not cover a lot of cases, e.g.:
or:
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 thatif
statement says).How was this patch tested?
Manual