[Django] #32030: Make Token Generator more universal

20 views
Skip to first unread message

Django

unread,
Sep 21, 2020, 9:17:51 PM9/21/20
to django-...@googlegroups.com
#32030: Make Token Generator more universal
----------------------------------------+------------------------
Reporter: Ilya Chichak | Owner: nobody
Type: New feature | Status: new
Component: contrib.auth | Version: 3.1
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 |
----------------------------------------+------------------------
I suggest to split current `PasswordResetTokenGenerator` into
`BaseTokenGenerator` and it's implementation `PasswordResetTokenGenerator`

To make `BaseTokenGenerator` more universal, it should contain class
variable `TOKEN_TIMEOUT` with token timeout and `_make_hash_value` method
public and abstract.

It will make possible to make email confirmation tokens, one time enter
tokens and other with reimplementing `make_hash_value` method and setting
separate timeout for each token generator. Current
`PasswordResetTokenGenerator` will be implementation of
`BaseTokenGenerator` where `TOKEN_TIMEOUT` will be
`settings.PASSWORD_RESET_TIMEOUT`. So, for all logic, that uses
`PasswordResetTokenGenerator` nothing will be changed.

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

Django

unread,
Sep 21, 2020, 9:18:05 PM9/21/20
to django-...@googlegroups.com
#32030: Make Token Generator more universal
------------------------------+----------------------------------------
Reporter: Ilya Chichak | Owner: Ilya Chichak
Type: New feature | Status: assigned
Component: contrib.auth | Version: 3.1
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 Ilya Chichak):

* owner: nobody => Ilya Chichak
* status: new => assigned


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

Django

unread,
Sep 22, 2020, 12:11:29 AM9/22/20
to django-...@googlegroups.com
#32030: Make Token Generator more universal
------------------------------+----------------------------------------
Reporter: Ilya Chichak | Owner: Ilya Chichak
Type: New feature | Status: closed
Component: contrib.auth | Version: 3.1
Severity: Normal | Resolution: duplicate

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 felixxm):

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


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

Django

unread,
Sep 22, 2020, 6:22:42 AM9/22/20
to django-...@googlegroups.com
#32030: Make Token Generator more universal
------------------------------+----------------------------------------
Reporter: Ilya Chichak | Owner: Ilya Chichak
Type: New feature | Status: closed
Component: contrib.auth | Version: 3.1
Severity: Normal | Resolution: duplicate

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+----------------------------------------

Comment (by Ilya Chichak):

@felixxm

In ticket you provided you said `PasswordResetTokenGenerator` is not
universal.
So, I made `BaseTokenGenerator` that is more universal and flexible and
not breaking current code.

Can I hear alternative opinion?

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

Django

unread,
Sep 22, 2020, 6:23:46 AM9/22/20
to django-...@googlegroups.com
#32030: Make Token Generator more universal
------------------------------+----------------------------------------
Reporter: Ilya Chichak | Owner: Ilya Chichak
Type: New feature | Status: closed
Component: contrib.auth | Version: 3.1
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+----------------------------------------
Changes (by Ilya Chichak):

* has_patch: 0 => 1


Old description:

> I suggest to split current `PasswordResetTokenGenerator` into
> `BaseTokenGenerator` and it's implementation
> `PasswordResetTokenGenerator`
>
> To make `BaseTokenGenerator` more universal, it should contain class
> variable `TOKEN_TIMEOUT` with token timeout and `_make_hash_value` method
> public and abstract.
>
> It will make possible to make email confirmation tokens, one time enter
> tokens and other with reimplementing `make_hash_value` method and setting
> separate timeout for each token generator. Current
> `PasswordResetTokenGenerator` will be implementation of
> `BaseTokenGenerator` where `TOKEN_TIMEOUT` will be
> `settings.PASSWORD_RESET_TIMEOUT`. So, for all logic, that uses
> `PasswordResetTokenGenerator` nothing will be changed.

New description:

I suggest to split current `PasswordResetTokenGenerator` into
`BaseTokenGenerator` and it's implementation `PasswordResetTokenGenerator`

To make `BaseTokenGenerator` more universal, it should contain class
variable `TOKEN_TIMEOUT` with token timeout and `_make_hash_value` method
public and abstract.

It will make possible to make email confirmation tokens, one time enter
tokens and other with reimplementing `make_hash_value` method and setting
separate timeout for each token generator. Current
`PasswordResetTokenGenerator` will be implementation of
`BaseTokenGenerator` where `TOKEN_TIMEOUT` will be
`settings.PASSWORD_RESET_TIMEOUT`. So, for all logic, that uses
`PasswordResetTokenGenerator` nothing will be changed.

https://github.com/django/django/pull/13444

--

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

Reply all
Reply to author
Forward
0 new messages