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
ModelBackend
only returns a user fromauthenticate
if
user_can_authenticate
isTrue
.The
OIDCAuthenticationBackend
doesn't checkuser_can_authenticate
,in its
authenticate
method, allowing a user to log-in that hasis_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
, expectingOIDCAuthenticationBackend
to call it the same as any otherModelBackend
.It seems proper for the
OIDCAuthenticationBackend
to verifyuser_can_authenticate
and it seems to me like there are no problemsassociated with doing so, so let's just call
user_can_authenticate
to resolve the problems described above.