Opened 10 years ago

Last modified 10 years ago

#23896 closed New feature

set_password delegation to auth backend — at Version 2

Reported by: Roman Owned by: nobody
Component: contrib.auth Version: 1.7
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Roman)

Recently I've implemented LDAP auth backend by myself and was confused by not being able to add change_password/set_password functionality without adding custom User model. Actually I think it is very common to delegate password validation to some external service, like LDAP, SMTP, HTTP, etc. while keeping User model as is. Also, providing custom user model will force all applications to reference settings.AUTH_USER_MODEL which is definitely correct, but forcing to do even correct thing does not look nice for me.

So, the thing I want to discuss is support of some special methods on auth backends like

""" user is for User model instance previously returned by this backend's authenticate method """
def set_password(self, user, new_password):
    pass

""" user is for User model instance previously returned by this backend's authenticate method """
def change_password(self, user, old_password, new_password):
    pass

User model to call auth backend methods if defined.

So do I miss anything? Is my proposal correct?

Change History (2)

comment:1 by Roman, 10 years ago

Summary: set_passwordset_password delegation to auth backend

comment:2 by Roman, 10 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top