Skip to content

added urllib.unquote to escape urlencoded strings in cookies #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions nginx-ldap-auth-daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# Requests are processed in separate thread
import threading
from SocketServer import ThreadingMixIn
import urllib
class AuthHTTPServer(ThreadingMixIn, HTTPServer):
pass
# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -51,7 +52,7 @@ def do_GET(self):
ctx['action'] = 'performing authorization'
auth_header = self.headers.get('Authorization')
auth_cookie = self.get_cookie(ctx['cookiename'])

auth_cookie = urllib.unquote(auth_cookie)
if auth_cookie != None and auth_cookie != '':
auth_header = "Basic " + auth_cookie
self.log_message("using username/password from cookie %s" %
Expand All @@ -71,9 +72,8 @@ def do_GET(self):
ctx['action'] = 'decoding credentials'

try:
auth_decoded = base64.b64decode(auth_header[6:])
auth_decoded = urllib.unquote(base64.b64decode(auth_header[6:]))
user, passwd = auth_decoded.split(':', 1)

except:
self.auth_failed(ctx)
return True
Expand Down Expand Up @@ -164,8 +164,7 @@ def get_params(self):
return self.params

# GET handler for the authentication request
def do_GET(self):

def do_GET(self):
ctx = dict()
self.ctx = ctx

Expand Down Expand Up @@ -213,8 +212,7 @@ def do_GET(self):
# ldap_obj.set_option(ldap.OPT_REFERRALS, 0)

ctx['action'] = 'binding as search user'
ldap_obj.bind_s(ctx['binddn'], ctx['bindpasswd'], ldap.AUTH_SIMPLE)

ldap_obj.bind_s(ctx['binddn'], ctx['bindpasswd'], ldap.AUTH_SIMPLE)
ctx['action'] = 'preparing search filter'
searchfilter = ctx['template'] % { 'username': ctx['user'] }

Expand Down