Skip to content

Commit

Permalink
Merge pull request #2991 from Nordix/username-fix
Browse files Browse the repository at this point in the history
Fix username parsing for basic auth
  • Loading branch information
benoitc committed May 11, 2023
2 parents f859de4 + 2b98f5e commit 4aca2e4
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions gunicorn/glogging.py
Expand Up @@ -469,10 +469,7 @@ def _get_user(self, environ):
# 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

0 comments on commit 4aca2e4

Please sign in to comment.