Add NTLM proxy authentication to urllib2

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • looping

    #1

    Add NTLM proxy authentication to urllib2

    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.

  • Jarek Zgoda

    #2
    Re: Add NTLM proxy authentication to urllib2

    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).

    --
    Jarek Zgoda

    Comment

    • John J. Lee

      #3
      Re: Add NTLM proxy authentication to urllib2

      Jarek Zgoda <jzgoda@o2.usun .plwrites:
      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).
      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

      Comment

      • looping

        #4
        Re: Add NTLM proxy authentication to urllib2

        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 ?

        Comment

        • John J. Lee

          #5
          Re: Add NTLM proxy authentication to urllib2

          "looping" <kadeko@gmail.c omwrites:
          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

          Comment

          Working...