HTTP Authentication and realms

Michael Foord fuzzyman at gmail.com
Sat Sep 4 14:29:02 EDT 2004


To be fair this is more a question about http than directly about
python... but I'm trying to work with it from python and would
appreciate some help.

I'm writing a cgiproxy to remotely fetch webpages and am struggling
with authentication. From the comments at
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/267197 I took
the code to do basic authentication when a server replies with a 401
error - but that only authenticates the first page. You then need to
use 'realm' information and something like
urllib2.HTTPPasswordMgrWithDefaultRealm (remembering the username and
password for the realm, once you have supplied it). The trouble is
that *my* code is a CGI. This means that for each seperate page access
the process starts afresh - so I would need to save in an external
file the username and password combinations... which is by no means an
ideal solution.

The bottom line for me is that I don't actually understand what a
realm is and how http does authentication beyond the first page access
- does it need the username and password encoded in the headers for
access to every page in that realm ?



Fuzzy

http://www.voidspace.org.uk/atlantibots/pythonutils.html



More information about the Python-list mailing list