From 0cfd451ffa43369ca51563e4ecd436319821fc20 Mon Sep 17 00:00:00 2001 From: Daniel Mursa Date: Mon, 16 Dec 2024 14:04:19 +0100 Subject: [PATCH] [#485] Update generate tokens --- src/objects/token/models.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/objects/token/models.py b/src/objects/token/models.py index 546901e3..91b5a256 100644 --- a/src/objects/token/models.py +++ b/src/objects/token/models.py @@ -1,5 +1,4 @@ -import binascii -import os +import secrets from django.core import exceptions from django.db import models @@ -81,7 +80,7 @@ def save(self, *args, **kwargs): return super().save(*args, **kwargs) def generate_token(self): - return binascii.hexlify(os.urandom(20)).decode() + return secrets.token_hex(20) def get_permission_for_object_type(self, object_type: ObjectType): if not self.permissions.filter(object_type=object_type).exists():