Basic Auth for simple web server
Michele Simionato
michele.simionato at gmail.com
Tue Jun 5 11:17:42 EDT 2007
On Jun 5, 4:28 pm, Marco Aloisio <m... at valis-e.com> wrote:
> Hi, I'm a Python newbie;
> I have to write a simple webserver, and I need to
> implement a basic authentication as specified in the RFC2617.
> I wonder if there is a Python library for doing that.
>
> Thanks!
>
> --
> Marco Aloisio
Have a look at paste (http://pythonpaste.org/).
For instance, to enable authentication for user foo, you can do the
following
from paste.auth.basic import AuthBasicHandler
def only_for_foo(env, user, passwd):
return user == 'foo' and passwd = 'bar'
auth_app = AuthBasicHandler(
myapp, 'app realm', only_for_foo)
(where myapp is your WSGI application, of course).
Michele Simionato
More information about the Python-list
mailing list