From 8b5cfc9c28cc39bfe23a6c621872b5b37e11530d Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 3 Sep 2021 09:57:04 +0200 Subject: [PATCH] Use token_hex from secrets instead of choice CURA-8401 --- cura/OAuth2/AuthorizationHelpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/OAuth2/AuthorizationHelpers.py b/cura/OAuth2/AuthorizationHelpers.py index c97c7f3ec2..d6f4980fe4 100644 --- a/cura/OAuth2/AuthorizationHelpers.py +++ b/cura/OAuth2/AuthorizationHelpers.py @@ -139,11 +139,11 @@ class AuthorizationHelpers: def generateVerificationCode(code_length: int = 32) -> str: """Generate a verification code of arbitrary length. - :param code_length:: How long should the code be? This should never be lower than 16, but it's probably + :param code_length:: How long should the code be in bytes? This should never be lower than 16, but it's probably better to leave it at 32 """ - return "".join(secrets.choice("0123456789ABCDEF") for i in range(code_length)) + return secrets.token_hex(code_length) @staticmethod def generateVerificationCodeChallenge(verification_code: str) -> str: