mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Merge pull request #1149 from benoitc/fix/gh1148
check if the auth type is Basic before getting the user name
This commit is contained in:
commit
f74dd0aa3c
@ -4,6 +4,7 @@
|
||||
# See the NOTICE for more information.
|
||||
|
||||
import base64
|
||||
import binascii
|
||||
import time
|
||||
import logging
|
||||
logging.Logger.manager.emittedNoHandlerWarning = 1
|
||||
@ -381,7 +382,7 @@ class Logger(object):
|
||||
def _get_user(self, environ):
|
||||
user = None
|
||||
http_auth = environ.get("HTTP_AUTHORIZATION")
|
||||
if http_auth:
|
||||
if http_auth and http_auth.startswith('Basic'):
|
||||
auth = http_auth.split(" ", 1)
|
||||
if len(auth) == 2:
|
||||
try:
|
||||
@ -394,6 +395,9 @@ class Logger(object):
|
||||
except TypeError as exc:
|
||||
self.debug("Couldn't get username: %s", exc)
|
||||
return user
|
||||
except binascii.Error as exc:
|
||||
self.debug("Couldn't get username: %s", exc)
|
||||
return user
|
||||
if len(auth) == 2:
|
||||
user = auth[0]
|
||||
return user
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user