mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-13 16:54:47 +03:00
Refactor token generation to use secrets module
This commit is contained in:
parent
64c3d9ef63
commit
c072a1f2a8
|
@ -1,5 +1,4 @@
|
||||||
import binascii
|
import secrets
|
||||||
import os
|
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
@ -34,7 +33,7 @@ class Token(models.Model):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def generate_key(cls):
|
def generate_key(cls):
|
||||||
return binascii.hexlify(os.urandom(20)).decode()
|
return secrets.token_hex(20)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.key
|
return self.key
|
||||||
|
|
Loading…
Reference in New Issue
Block a user