Opened 3 months ago

Closed 3 months ago

#33696 closed Cleanup/optimization (wontfix)

Add a fail fast option to validate_password().

Reported by: Parth Verma Owned by: nobody
Component: contrib.auth Version: dev
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


Right now, the validate_password function runs all the validators in the list. However, while implementing something like a validator to prevent password reuse, we might want the user to resolve all the other validation errors before running an expensive DB operation. Adding a fail fast option might be helpful here as it will allow to resolve validation errors as they appear rather than running all the validators again everytime.

Change History (1)

comment:1 Changed 3 months ago by Mariusz Felisiak

Has patch: unset
Resolution: wontfix
Status: newclosed
Summary: Add a fail fast option to validate_passwordAdd a fail fast option to validate_password().

Thanks for this ticket, however it looks quite niche. In most of cases it's preferable to return all validation errors to users, without unnecessary round-trip. You can always pass the password_validators argument in your own code to fail-fast on non-expensive validators, e.g.

validate_password(password, user, password_validators=non-db-validators)
validate_password(password, user, password_validators=expensive-db-validators)
Note: See TracTickets for help on using tickets.
Back to Top