Repository navigation
Refuse registration and passwords while local authentication is disabled - #1103
Conversation
With OIDC enabled and OIDC_DISABLE_LOCAL_AUTH set, a user registered with a password could never log in. The register endpoint now returns 405, as with REGISTRATION_DISABLED. Without OIDC the setting has no effect, as for the token endpoint. Closes gramps-project#778
|
Thanks! Review suggestion:
|
Move the condition `is_oidc_enabled()` and `OIDC_DISABLE_LOCAL_AUTH` into `is_local_auth_disabled()` in `auth/oidc_helpers.py` and use it in the token, OIDC config, OIDC accounts and register endpoints. Tests that patched `is_oidc_enabled` in the resource modules patch it in `oidc_helpers` instead. The register endpoint checks whether registration is disabled before it requires a tree, so a multi-tree request without a tree also gets 405. The test checks that no email is sent while registration is disabled.
With OIDC enabled and OIDC_DISABLE_LOCAL_AUTH set, a password can never be used to log in. Adding a user with a password, create_owner, changing the password and the password reset (trigger, form and submit) now return 405, as registration does. The reset trigger sends no email.
|
All four points are addressed in d177f2b and 7d2c613.
Each new check has a test that fails when the check is removed. Full suite without addons installed, as in CI: 2784 passed, 15 skipped. Drafted with Claude Code (AI assistant). |
Closes #778.
Change: With OIDC enabled and
OIDC_DISABLE_LOCAL_AUTHset, the endpoints that take a password return 405:POST /api/users/<user_name>/register/, "Registration is disabled"), checked before the tree argument;create_owner, changing the password and the password reset (trigger, form and submit), "Local authentication is disabled"; the reset trigger sends no email.The condition is
is_local_auth_disabled()inauth/oidc_helpers.py, now shared by the token, OIDC config, OIDC accounts and user endpoints. It requiresOIDC_ENABLEDin addition toOIDC_DISABLE_LOCAL_AUTH, as the token endpoint did before: while OIDC is disabled,OIDC_DISABLE_LOCAL_AUTHhas no effect on password login.Tests: One test per endpoint in
tests/test_endpoints/test_user.py: with both settings, 405 and no change to users or passwords; with onlyOIDC_DISABLE_LOCAL_AUTH, the request succeeds. Removing any single check makes its test fail. Full suite without addons installed, as in CI: 2784 passed, 15 skipped.Drafted with Claude Code (AI assistant).