#32553: Allow UserAttributeSimilarityValidator to validate against fields of
related models
------------------------------+--------------------------------------
     Reporter:  Meiyer        |                    Owner:  nobody
         Type:  New feature   |                   Status:  new
    Component:  contrib.auth  |                  Version:  dev
     Severity:  Normal        |               Resolution:
     Keywords:                |             Triage Stage:  Unreviewed
    Has patch:  0             |      Needs documentation:  0
  Needs tests:  0             |  Patch needs improvement:  0
Easy pickings:  0             |                    UI/UX:  0
------------------------------+--------------------------------------
Description changed by Meiyer:

Old description:

> The password validator `UserAttributeSimilarityValidator` is currently
> too rigid and allows comparison of the password only to the fields of the
> `User` model, while ignoring the common case where there is also a
> profile attached to the user (as a separate model). My suggestion is to
> relax the attribute resolution so that also fields defined on related
> models could be accessed; for example, by traversing a dotted path as in
> `reduce(getattr, path.split('.'), obj)`.
>
> Yet a better option could be to allow plugging into the validator by
> means of an overridable method `get_user_attribute(self, attribute_name)`
> used instead of a direct `getattr`, that will allow more customisation
> while leaving the validation logic intact.

New description:

 The password validator `UserAttributeSimilarityValidator` is currently too
 rigid and allows comparison of the password only to the fields of the
 `User` model, while ignoring the common case where there is also a profile
 attached to the user (as a separate model). My suggestion is to relax the
 attribute resolution so that also fields defined on related models could
 be accessed; for example, by traversing a dotted path as in
 `reduce(getattr, path.split('.'), obj)`.

 Yet a better option could be to allow plugging into the validator by means
 of an overridable method `get_user_attribute(self, attribute_name)` used
 instead of a direct `getattr`, that will allow more customisation while
 leaving the validation logic intact.

 (Related to #26909 and #28127)

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32553#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.affad922e10137b43a08cb8874111da1%40djangoproject.com.

Reply via email to