summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Brondsema <dave@brondsema.net>2020-10-12 08:22:52 -0400
committerGitHub <noreply@github.com>2020-10-12 13:22:52 +0100
commit0370a8368fb5e2019dce4261c8a113f6cd41347e (patch)
tree0d9d163043cc2c31082a96bd354476379bdaecbc
parentc9525141df14dd567caa246ab5c77a9825b90b3a (diff)
downloadpaste-git-0370a8368fb5e2019dce4261c8a113f6cd41347e.tar.gz
Fix AuthBasicAuthenticator base64 decoding to work on py3 (#61)
-rw-r--r--paste/auth/basic.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/paste/auth/basic.py b/paste/auth/basic.py
index 24d1731..adfd5ae 100644
--- a/paste/auth/basic.py
+++ b/paste/auth/basic.py
@@ -21,6 +21,8 @@ serving on...
.. [1] http://www.w3.org/Protocols/HTTP/1.0/draft-ietf-http-spec.html#BasicAA
"""
+from base64 import b64decode
+import six
from paste.httpexceptions import HTTPUnauthorized
from paste.httpheaders import *
@@ -44,7 +46,7 @@ class AuthBasicAuthenticator(object):
(authmeth, auth) = authorization.split(' ', 1)
if 'basic' != authmeth.lower():
return self.build_authentication()
- auth = auth.strip().decode('base64')
+ auth = six.ensure_text(b64decode(six.ensure_binary(auth.strip())))
username, password = auth.split(':', 1)
if self.authfunc(environ, username, password):
return username