Fix username parsing for basic auth

This commit is contained in:
Tero Saarni 2023-05-11 16:32:14 +03:00
parent f859de498a
commit 2b98f5e7b7

View File

@ -469,10 +469,7 @@ class Logger(object):
# so we need to convert it to a byte string
auth = base64.b64decode(auth[1].strip().encode('utf-8'))
# b64decode returns a byte string
auth.split(b":", 1)[0].decode("UTF-8", "replace")
user = auth.split(b":", 1)[0].decode("UTF-8")
except (TypeError, binascii.Error, UnicodeDecodeError) as exc:
self.debug("Couldn't get username: %s", exc)
return user
if len(auth) == 2:
user = auth[0]
return user