Use secrets module to generate token nonce

This commit is contained in:
Sonny Bakker 2025-05-04 09:04:07 +02:00
parent 654a123458
commit 6d371c13d7

View file

@ -1,9 +1,9 @@
import base64 import base64
import json import json
import logging import logging
import time
from concurrent.futures import ThreadPoolExecutor, as_completed from concurrent.futures import ThreadPoolExecutor, as_completed
from secrets import token_urlsafe
from typing import Generator from typing import Generator
import requests import requests
@ -28,7 +28,7 @@ def _get_token(private_key_path: str, login: str, api_url: str) -> str:
f"{api_url}/auth", f"{api_url}/auth",
json={ json={
"login": login, "login": login,
"nonce": str(int(time.time() * 1000)), "nonce": token_urlsafe(),
"read_only": False, "read_only": False,
"expiration_time": "30 minutes", "expiration_time": "30 minutes",
"label": "Trans IP client", "label": "Trans IP client",