Add NTLM proxy authentication to urllib2

L

looping

Hi,
I have to make internet connections through an ISA proxy server that
use NTLM or Kerberos authorization method.
I've found a program in python called ntlmaps that act like a proxy and
could make the NTLM authentication, but you have to run it and make all
your connection through it, not an optimal solution.
So what I really need is an enhanced urllib2 that support NTLM or
Kerberos.
I've found that pywin32 could manage NTLM encryption with the sspi
module but I've no idea how to implement it in urllib2, NTLM
authentication use a 'Token dance' between client and server.

Anyone has an experience, a demo or an idea to share ?

Thanks.
 
J

Jarek Zgoda

looping napisa³(a):
I have to make internet connections through an ISA proxy server that
use NTLM or Kerberos authorization method.
I've found a program in python called ntlmaps that act like a proxy and
could make the NTLM authentication, but you have to run it and make all
your connection through it, not an optimal solution.
So what I really need is an enhanced urllib2 that support NTLM or
Kerberos.
I've found that pywin32 could manage NTLM encryption with the sspi
module but I've no idea how to implement it in urllib2, NTLM
authentication use a 'Token dance' between client and server.

Anyone has an experience, a demo or an idea to share ?

Look at NTLM APS (http://ntlmaps.sourceforge.net/), Dimitry did this
already (although not in urllib).
 
J

John J. Lee

Jarek Zgoda said:
looping napisał(a):


Look at NTLM APS (http://ntlmaps.sourceforge.net/), Dimitry did this
already (although not in urllib).

I *think* I remember somebody did implement NTLM for urllib2. Keep
googling^W employing popular internet free-text search facilities.

But probably a proxy server like the one Jarek mentions is a much more
practical way to go.


John
 
L

looping

Thanks for the answers.

I've done some tests with urllib2 and pywin32 and managed to partialy
implement the NTLM authentication, but it look like you need a
persistent connection (http 1.1 or 'Keep-Alive') to complete the
authentication.
Unfortunatly, urllib2 use a new connection for each request and
changing this behavior look difficult.
So I will probably write my own library.

Maybe there is something to do with the urlgrabber module ?
 
J

John J. Lee

looping said:
I've done some tests with urllib2 and pywin32 and managed to partialy
implement the NTLM authentication, but it look like you need a
persistent connection (http 1.1 or 'Keep-Alive') to complete the
authentication.
Unfortunatly, urllib2 use a new connection for each request and
changing this behavior look difficult.
So I will probably write my own library.

Maybe there is something to do with the urlgrabber module ?

urlgrabber does indeed claim to do persistent connections in a way at
least somewhat integrated with urllib2.

I think I must have imagined there being an NTLM impl. for urllib2,
because ISTR you're right about needing a persistent connection.

I don't think it's too hard to fix urllib2 to reuse connections, but I
forget exactly why it doesn't do it already...


John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top