Verify user_can_authenticate when authenticating user - #379
Conversation
The standard Django `ModelBackend` only returns a user from `authenticate` if `user_can_authenticate` is `True`. The `OIDCAuthenticationBackend` doesn't check `user_can_authenticate`, in its `authenticate` method, allowing a user to log-in that has `is_active` set to `False`. This behavior is a surprising deviation from the way `ModelBackend` works. It can lead to security problems because other important authentication checks may inadvertently be bypassed, if the user implements them in `user_can_authenticate`, expecting `OIDCAuthenticationBackend` to call it the same as any other `ModelBackend`. It seems proper for the `OIDCAuthenticationBackend` to verify `user_can_authenticate` and it seems to me like there are no problems associated with doing so, so let's just call `user_can_authenticate` to resolve the problems described above.
Codecov Report
@@ Coverage Diff @@
## master #379 +/- ##
==========================================
+ Coverage 89.60% 89.62% +0.02%
==========================================
Files 7 7
Lines 481 482 +1
==========================================
+ Hits 431 432 +1
Misses 50 50
Continue to review full report at Codecov.
|
|
Is there any update on this, by any chance? 🤔 |
|
Any chance this can be reviewed and/or discussed? It is sitting without review for over half a year now. 😥 |
|
Noticed this as well. This could be a result of old Django conventions, but it feels dangerous to leave it up to the view since nowadays Django handles it in the authbackend, and like noted above developers may expect that of other authbackends that inherit from As for the PR, is there a specific reason why the check is made in Is the Would creating an issue help get this PR forward? |
The standard Django
ModelBackendonly returns a user fromauthenticateif
user_can_authenticateisTrue.The
OIDCAuthenticationBackenddoesn't checkuser_can_authenticate,in its
authenticatemethod, allowing a user to log-in that hasis_activeset to
False.This behavior is a surprising deviation from the way
ModelBackendworks.
It can lead to security problems because other important
authentication checks may inadvertently be bypassed, if the user
implements them in
user_can_authenticate, expectingOIDCAuthenticationBackendto call it the same as any otherModelBackend.It seems proper for the
OIDCAuthenticationBackendto verifyuser_can_authenticateand it seems to me like there are no problemsassociated with doing so, so let's just call
user_can_authenticateto resolve the problems described above.