From 13b1b89af3b1db34a63d3d4009ebff9e0855b809 Mon Sep 17 00:00:00 2001 From: Hanne Moa Date: Thu, 29 Feb 2024 08:11:13 +0100 Subject: [PATCH] Remove an adaption to Pythons older than 3.7 --- python/nav/web/auth/remote_user.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/python/nav/web/auth/remote_user.py b/python/nav/web/auth/remote_user.py index 83a9591bed..ba89860614 100644 --- a/python/nav/web/auth/remote_user.py +++ b/python/nav/web/auth/remote_user.py @@ -18,27 +18,13 @@ """ import logging from os.path import join +import secrets from nav.auditlog.models import LogEntry from nav.config import NAVConfigParser from nav.models.profiles import Account from nav.web.auth.utils import ACCOUNT_ID_VAR -try: - # Python 3.6+ - import secrets - - def fake_password(length): - return secrets.token_urlsafe(length) - -except ImportError: - from random import choice - import string - - def fake_password(length): - symbols = string.ascii_letters + string.punctuation + string.digits - return u"".join(choice(symbols) for i in range(length)) - __all__ = [] @@ -61,6 +47,10 @@ class RemoteUserConfigParser(NAVConfigParser): _config = RemoteUserConfigParser() +def fake_password(length): + return secrets.token_urlsafe(length) + + def authenticate(request): """Authenticate username from http header REMOTE_USER