Verify user_can_authenticate when authenticating user #379
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.