[Django] #28017: Add option to specify a different secret to PasswordResetTokenGenerator

44 views
Skip to first unread message

Django

unread,
Apr 4, 2017, 2:34:42 PM4/4/17
to django-...@googlegroups.com
#28017: Add option to specify a different secret to PasswordResetTokenGenerator
----------------------------------------+------------------------
Reporter: jannh | Owner: nobody
Type: New feature | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------+------------------------
In the PasswordResetTokenGenerator class, it is very difficult to use a
secret different from settings.SECRET_KEY. In Django however, it would be
very easy to add an attribute "secret" to the class, which defaults to
settings.SECRET_KEY and is handed to "salted_hmac" in the method
"_make_token_with_timestamp".

Currently, one would have to overwrite the _make_token_with_timestamp
method, which is not documented and likely to change, or one could misuse
modify_settings or override_settings in production.

Our usecase is, that we have a site for our employees and a self-service-
site for customers deployed on different servers and with different
SECRET_KEYs. Both sites should be able to generate Reset-Links for the
self-service site.

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

Django

unread,
Apr 4, 2017, 2:43:35 PM4/4/17
to django-...@googlegroups.com
#28017: Add option to specify a different secret to PasswordResetTokenGenerator
------------------------------+--------------------------------------
Reporter: Jann Haber | Owner: Jann Haber
Type: New feature | Status: assigned
Component: contrib.auth | Version: master
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
------------------------------+--------------------------------------
Changes (by Jann Haber):

* owner: nobody => Jann Haber
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/28017#comment:1>

Django

unread,
Apr 4, 2017, 3:10:47 PM4/4/17
to django-...@googlegroups.com
#28017: Add option to specify a different secret to PasswordResetTokenGenerator
------------------------------+--------------------------------------
Reporter: Jann Haber | Owner: Jann Haber
Type: New feature | Status: assigned
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0

------------------------------+--------------------------------------
Changes (by Jann Haber):

* has_patch: 0 => 1
* easy: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/28017#comment:2>

Django

unread,
Apr 5, 2017, 3:35:47 AM4/5/17
to django-...@googlegroups.com
#28017: Add option to specify a different secret to PasswordResetTokenGenerator
------------------------------+--------------------------------------
Reporter: Jann Haber | Owner: Jann Haber
Type: New feature | Status: assigned
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by Claude Paroz):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/28017#comment:3>

Django

unread,
May 18, 2017, 12:46:48 PM5/18/17
to django-...@googlegroups.com
#28017: Add option to specify a different secret to PasswordResetTokenGenerator
------------------------------+--------------------------------------
Reporter: Jann Haber | Owner: Jann Haber
Type: New feature | Status: assigned
Component: contrib.auth | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 1 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/28017#comment:4>

Django

unread,
May 19, 2017, 12:56:58 PM5/19/17
to django-...@googlegroups.com
#28017: Add option to specify a different secret to PasswordResetTokenGenerator
------------------------------+--------------------------------------
Reporter: Jann Haber | Owner: Jann Haber
Type: New feature | Status: assigned
Component: contrib.auth | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by Jann Haber):

* needs_better_patch: 1 => 0


Comment:

I updated the PR according to Tim's comments. Thank you for the review!

--
Ticket URL: <https://code.djangoproject.com/ticket/28017#comment:5>

Django

unread,
May 26, 2017, 7:37:58 AM5/26/17
to django-...@googlegroups.com
#28017: Add option to specify a different secret to PasswordResetTokenGenerator
------------------------------+--------------------------------------
Reporter: Jann Haber | Owner: Jann Haber
Type: New feature | Status: closed
Component: contrib.auth | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"c930c241f8f1ccf3a7848b843628eacdb983d70a" c930c24]:
{{{
#!CommitTicketReference repository=""
revision="c930c241f8f1ccf3a7848b843628eacdb983d70a"
Fixed #28017 -- Allowed customizing PasswordResetTokenGenerator's secret.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28017#comment:6>

Django

unread,
Apr 20, 2021, 2:45:48 AM4/20/21
to django-...@googlegroups.com
#28017: Add option to specify a different secret to PasswordResetTokenGenerator
------------------------------+--------------------------------------
Reporter: Jann Haber | Owner: Jann Haber
Type: New feature | Status: closed
Component: contrib.auth | Version: dev

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+--------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"b13af4752fa3e5e7c08163902f32260a50f69ef7" b13af47]:
{{{
#!CommitTicketReference repository=""
revision="b13af4752fa3e5e7c08163902f32260a50f69ef7"
Refs #28017 -- Added test for PasswordResetTokenGenerator subclass with a
custom secret.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28017#comment:7>

Reply all
Reply to author
Forward
0 new messages