From 680744a57910205d17ffa59736fd8cfdd2583127 Mon Sep 17 00:00:00 2001 From: Guntram Blohm Date: Wed, 2 Apr 2014 11:35:08 +0200 Subject: [PATCH 1/2] Add an Option NameCase that can be set to 'lower' or 'upper', which will convert REMOTE_USER to lower/uppercase. Any other string, as well as not setting the option, will leave REMOTE_USER alone. --- pyntlm.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pyntlm.py b/pyntlm.py index 9d3f219..5da4644 100644 --- a/pyntlm.py +++ b/pyntlm.py @@ -167,6 +167,12 @@ def set_remote_user(req, username, domain): req.user = domain + '\\' + username else: req.user = username + namecase = req.get_options().get('NameCase', 'ignore').lower() + if namecase == 'lower': + req.user = req.user.lower() + elif namecase == 'upper': + req.user = req.user.upper() + def decode_http_authorization_header(auth): '''Return a tuple with the parsed content of an HTTP Authorization header From 8102aba13cf9953aa51df3bbcdf0ec6f19094780 Mon Sep 17 00:00:00 2001 From: Guntram Blohm Date: Wed, 2 Apr 2014 11:38:39 +0200 Subject: [PATCH 2/2] (At least some versions of) Apache will always log APLOG_NOTICE, independent of LogLevel, which produces a lot of spam in error_log. Changed Log Level APLOG_NOTICE to APLOG_INFO to prevent this. --- pyntlm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyntlm.py b/pyntlm.py index 5da4644..8749f0c 100644 --- a/pyntlm.py +++ b/pyntlm.py @@ -339,7 +339,7 @@ def handle_type3(req, ntlm_message): domain,user,req.unparsed_uri)) return handle_unauthorized(req) - req.log_error('PYNTLM: User %s/%s has been authenticated to access URI %s' % (user,domain,req.unparsed_uri), apache.APLOG_NOTICE) + req.log_error('PYNTLM: User %s/%s has been authenticated to access URI %s' % (user,domain,req.unparsed_uri), apache.APLOG_INFO) set_remote_user(req, user, domain) result = check_authorization(req, user, proxy) cache.remove(req.connection.id) @@ -373,7 +373,7 @@ def handle_basic(req, user, password): user,domain,req.unparsed_uri)) return handle_unauthorized(req) - req.log_error('PYNTLM: User %s/%s has been authenticated (Basic) to access URI %s' % (user,domain,req.unparsed_uri), apache.APLOG_NOTICE) + req.log_error('PYNTLM: User %s/%s has been authenticated (Basic) to access URI %s' % (user,domain,req.unparsed_uri), apache.APLOG_INFO) set_remote_user(req, user, domain) result = check_authorization(req, user, proxy) proxy.close()