> While we’re there, we should use
https://docs.python.org/3/library/secrets.html#module-secrets on Python >=
3.6.
--
Ticket URL: <https://code.djangoproject.com/ticket/27635>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* type: New feature => Cleanup/optimization
* stage: Unreviewed => Accepted
Comment:
Specifically, it looks like that means in place of `random.SystemRandom`.
--
Ticket URL: <https://code.djangoproject.com/ticket/27635#comment:1>
* cc: desecho@… (added)
* has_patch: 0 => 1
* version: 1.10 => master
Comment:
Added [https://github.com/django/django/pull/7756 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/27635#comment:2>
* has_patch: 1 => 0
* stage: Accepted => Someday/Maybe
Comment:
Python's `secrets.py` does `from random import SystemRandom` so this
doesn't change any behavior or add security for now. Adam said,
"Presumably the intention is that secrets might one day use a different
PRNG's on some OS's." Let's make the change if the benefits become more
than theoretical or when only Python 3.6+ is supported.
Another possibility Aymeric mentioned, "In the long run I think we should
deprecate get_random_string in favor of similar functions provided by the
secrets module. I didn't check whether there was a sensible transition
plan to make use of secrets on Python 3.6 while still supporting older
versions."
--
Ticket URL: <https://code.djangoproject.com/ticket/27635#comment:3>
Comment (by Emett Speer):
Replying to [comment:3 Tim Graham]:
> Python's `secrets.py` does `from random import SystemRandom` so this
doesn't change any behavior or add security for now. Adam said,
"Presumably the intention is that secrets might one day use a different
PRNG's on some OS's." Let's make the change if the benefits become more
than theoretical or when only Python 3.6+ is supported.
>
> Another possibility Aymeric mentioned, "In the long run I think we
should deprecate get_random_string in favor of similar functions provided
by the secrets module. I didn't check whether there was a sensible
transition plan to make use of secrets on Python 3.6 while still
supporting older versions."
I'm with you on this. The vast majority of people are not going to use
this for a long time and it will add an extra bit of overhead just to
support an update in a single version of Python none of the big distros
ship. Once more of the Django community has migrated to Python3.6+ it
would be worth looking into.
--
Ticket URL: <https://code.djangoproject.com/ticket/27635#comment:4>
* has_patch: 0 => 1
Comment:
New [https://github.com/django/django/pull/11357 PR] now we are on 3.6+.
--
Ticket URL: <https://code.djangoproject.com/ticket/27635#comment:5>
* owner: nobody => Nick Pope
* status: new => assigned
* stage: Someday/Maybe => Accepted
Comment:
Alternate [https://github.com/django/django/pull/11368 PR] addressing the
non-working fallback and optionally stripping it out based on
[https://github.com/django/django/pull/11357#issuecomment-492839409 my
comment].
--
Ticket URL: <https://code.djangoproject.com/ticket/27635#comment:6>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"068005a349f80b3c6c724cc7a2d0b0c44413f463" 068005a3]:
{{{
#!CommitTicketReference repository=""
revision="068005a349f80b3c6c724cc7a2d0b0c44413f463"
Refs #27635 -- Removed fallback when SystemRandom() isn't available that
doesn't work.
Fallback was untested and likely never triggered.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27635#comment:7>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"1d0bab0bfd77edcf1228d45bf654457a8ff1890d" 1d0bab0]:
{{{
#!CommitTicketReference repository=""
revision="1d0bab0bfd77edcf1228d45bf654457a8ff1890d"
Fixed #27635 -- Used secrets module in django.utils.crypto.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27635#comment:8>