Package cherrypy :: Package lib :: Module auth_basic
[hide private]
[frames] | no frames]

Module auth_basic

source code

This module provides a CherryPy 3.x tool which implements the server-side of HTTP Basic Access Authentication, as described in :rfc:`2617`.

Example usage, using the built-in checkpassword_dict function which uses a dict as the credentials store:

   userpassdict = {'bird' : 'bebop', 'ornette' : 'wayout'}
   checkpassword = cherrypy.lib.auth_basic.checkpassword_dict(userpassdict)
   basic_auth = {'tools.auth_basic.on': True,
                 'tools.auth_basic.realm': 'earth',
                 'tools.auth_basic.checkpassword': checkpassword,
   }
   app_config = { '/' : basic_auth }

Date: April 2009

Author: visteya

Functions [hide private]
 
checkpassword_dict(user_password_dict)
Returns a checkpassword function which checks credentials against a dictionary of the form: {username : password}.
source code
 
basic_auth(realm, checkpassword, debug=False)
A CherryPy tool which hooks at before_handler to perform HTTP Basic Access Authentication, as specified in :rfc:`2617`.
source code
Variables [hide private]
  __doc__ = """This module provides a CherryPy 3.x tool which im...
  __package__ = 'cherrypy.lib'
Function Details [hide private]

checkpassword_dict(user_password_dict)

source code 

Returns a checkpassword function which checks credentials against a dictionary of the form: {username : password}.

If you want a simple dictionary-based authentication scheme, use checkpassword_dict(my_credentials_dict) as the value for the checkpassword argument to basic_auth().

basic_auth(realm, checkpassword, debug=False)

source code 
A CherryPy tool which hooks at before_handler to perform
HTTP Basic Access Authentication, as specified in :rfc:`2617`.

If the request has an 'authorization' header with a 'Basic' scheme, this
tool attempts to authenticate the credentials supplied in that header.  If
the request has no 'authorization' header, or if it does but the scheme is
not 'Basic', or if authentication fails, the tool sends a 401 response with
a 'WWW-Authenticate' Basic header.

realm
    A string containing the authentication realm.

checkpassword
    A callable which checks the authentication credentials.
    Its signature is checkpassword(realm, username, password). where
    username and password are the values obtained from the request's
    'authorization' header.  If authentication succeeds, checkpassword
    returns True, else it returns False.


Variables Details [hide private]

__doc__

Value:
"""This module provides a CherryPy 3.x tool which implements
the server-side of HTTP Basic Access Authentication, as described in :\
rfc:`2617`.

Example usage, using the built-in checkpassword_dict function which us\
es a dict
as the credentials store::

...