pegasy / python-ntlm

Automatically exported from code.google.com/p/python-ntlm
0 stars 0 forks source link

Case issue with auth header when using ntlm proxy #45

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Configure an NTLM PROXY server (I am using BlueCoat)
2. Attempt to authenticate against the proxy
3. I know these are bad steps, please read on....

What is the expected output? What do you see instead?

I was receiving HTTP 407 errors from the proxy.  After digging into the code 
and tcpdump, I noticed that NTLM Auth string was the same for the 1st and 2nd 
request.

What version of the product are you using? On what operating system?

Python 2.7.7 on CentOS.  python-ntlm version 1.0.1

Please provide any additional information below.

From what I saw on my setup, this was a simple case of the initial header being 
set as 'Proxy_authentication', then name.title() being called on the headers 
dict which turned 'Proxy_authentication' into 'Proxy_Authentication' (case 
change on the '_a').

So when it constructs the second response, instead of the auth header being 
replaced, it adds the upper case version.  So I had 'Proxy_authentication' and 
'Proxy_Authentication' in my headers dict.

I fixed it by changing line 109 in HTTPNtlmAuthHandler.py

- auth_header = 'Proxy-authorization'
+ auth_header = 'Proxy-Authorization' 

(Maybe calling .title() on it would be a better fix)

..That's it.  I feel like I am missing something obvious here as this seems 
like a simple fix that should have been caught by the first person to use this 
code.

Original issue reported on code.google.com by dwaterst...@gmail.com on 10 Jul 2014 at 2:39