Skip to content

Commit

Permalink
Remove an adaption to Pythons older than 3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
hmpf committed Feb 29, 2024
1 parent cbdf13f commit 13b1b89
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions python/nav/web/auth/remote_user.py
Expand Up @@ -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__ = []

Expand All @@ -61,6 +47,10 @@ class RemoteUserConfigParser(NAVConfigParser):
_config = RemoteUserConfigParser()


def fake_password(length):
return secrets.token_urlsafe(length)

Check warning on line 51 in python/nav/web/auth/remote_user.py

View check run for this annotation

Codecov / codecov/patch

python/nav/web/auth/remote_user.py#L51

Added line #L51 was not covered by tests


def authenticate(request):
"""Authenticate username from http header REMOTE_USER
Expand Down

0 comments on commit 13b1b89

Please sign in to comment.