This commit is contained in:
Mattias Jiderhamn 2023-03-05 15:34:28 +07:00 committed by GitHub
commit 86a49391f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -68,7 +68,8 @@ class AuthHandler(BaseHTTPRequestHandler):
ctx['action'] = 'performing authorization' ctx['action'] = 'performing authorization'
auth_header = self.headers.get('Authorization') auth_header = self.headers.get('Authorization')
auth_cookie = self.get_cookie(ctx['cookiename']) cookiename = ctx['cookiename']
auth_cookie = self.get_cookie(cookiename)
if auth_cookie != None and auth_cookie != '': if auth_cookie != None and auth_cookie != '':
auth_header = "Basic " + auth_cookie auth_header = "Basic " + auth_cookie
@ -89,6 +90,9 @@ class AuthHandler(BaseHTTPRequestHandler):
ctx['action'] = 'decoding credentials' ctx['action'] = 'decoding credentials'
try: try:
if cookiename != None and cookiename != '':
ctx['cookievalue'] = auth_header[6:]
auth_decoded = base64.b64decode(auth_header[6:]) auth_decoded = base64.b64decode(auth_header[6:])
if sys.version_info.major == 3: auth_decoded = auth_decoded.decode("utf-8") if sys.version_info.major == 3: auth_decoded = auth_decoded.decode("utf-8")
user, passwd = auth_decoded.split(':', 1) user, passwd = auth_decoded.split(':', 1)
@ -274,6 +278,10 @@ class LDAPAuthHandler(AuthHandler):
# Successfully authenticated user # Successfully authenticated user
self.send_response(200) self.send_response(200)
cookievalue = ctx['cookievalue']
if cookievalue != None:
# Cookie.SimpleCookie() causes issues with double quotes
self.send_header("Set-Cookie", "%s=%s" % (ctx['cookiename'], cookievalue))
self.end_headers() self.end_headers()
except: except: