# HG changeset patch # User paulb # Date 1076276522 0 # Node ID 95e17b0514193556e454bf2c94700ae8cce37b03 # Parent 3ea524db35d486534f6ac168f14efe6323e7eb17 [project @ 2004-02-08 21:42:02 by paulb] Added a helper module for authentication/authorisation. diff -r 3ea524db35d4 -r 95e17b051419 WebStack/Helpers/Auth.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WebStack/Helpers/Auth.py Sun Feb 08 21:42:02 2004 +0000 @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +""" +Authentication/authorisation helper classes and functions. +""" + +import base64 + +class UserInfo: + + """ + A class used to represent user information in terms of the authentication + scheme employed and the user details. + """ + + def __init__(self, auth_header): + + """ + Initialise the object with the value of the 'auth_header' - that is, the + HTTP Authorization header. + """ + + self.scheme, auth_details = auth_header.split(" ") + if self.scheme == "Basic": + + # NOTE: Assume that no username or password contains ":". + + self.username, self.password = base64.decodestring(auth_details).split(":") + + else: + + # NOTE: Other schemes not yet supported. + + self.username, self.password = None, None + +# vim: tabstop=4 expandtab shiftwidth=4