[Patches] [ python-Patches-812285 ] More precise realm parsing in AbstractBasicAuthHandler

SourceForge.net noreply at sourceforge.net
Thu Sep 25 04:47:38 EDT 2003


Patches item #812285, was opened at 2003-09-25 10:47
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=812285&group_id=5470

Category: Library (Lib)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Federico Di Carlo (federicodc)
Assigned to: Nobody/Anonymous (nobody)
Summary: More precise realm parsing in AbstractBasicAuthHandler

Initial Comment:
AbstractBasicAuthHandler class parses headers to search

for a scheme and its realm.



"rx" is the compiled regular expression that is used to

match these items. But it doesn't work on multiple

auth-schemes (as stated in urllib2.py source code).

Since I HAD to work around this issue (we have NTLM

authentication first in our proxy) I managed a bit the

regular expression (rx) and its groups.



The auth-request I had to face is:  

< NTLM, Basic realm="something" >, so I created a RE

with named groups to find exactly the type of request

that has a "realm" after the scheme, and that can

contain commas, in this way:

< ([ \t]+|(.*,)+)*(?P<scheme>[^ \t]+)[

\t]+realm="(?P<realm>[^"]*)"' >



Matching groups "scheme" and "realm" will contain right

values as parsed.



This will NOT fix issue with multiple realm-based

requests (it will return only last one), but seems to

handle well requests like the one specified.



Diff attached for Python 2.3



Hope this helps,



Federico Di Carlo



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=812285&group_id=5470



More information about the Patches mailing list