Use secrets instead of random

Since we're no longer stuck on python 3.5, we can use secrets instead of random
which provides better randomness.

CURA-8401
SEC-207
This commit is contained in:
Jaime van Kessel 2021-09-02 14:25:57 +02:00
parent 3caee3f143
commit e24a844d17

View file

@ -3,7 +3,7 @@
from datetime import datetime from datetime import datetime
import json import json
import random import secrets
from hashlib import sha512 from hashlib import sha512
from base64 import b64encode from base64 import b64encode
from typing import Optional from typing import Optional
@ -143,7 +143,7 @@ class AuthorizationHelpers:
better to leave it at 32 better to leave it at 32
""" """
return "".join(random.choice("0123456789ABCDEF") for i in range(code_length)) return "".join(secrets.choice("0123456789ABCDEF") for i in range(code_length))
@staticmethod @staticmethod
def generateVerificationCodeChallenge(verification_code: str) -> str: def generateVerificationCodeChallenge(verification_code: str) -> str: