Module Assign NameStore Str Assign NameStore Str Assign NameStore Str Import alias ImportFrom alias alias Import alias ImportFrom alias alias Assign NameStore Lambda arguments args NameParam defaults Call AttributeLoad Call NameLoad Call NameLoad NameLoad attr Assign NameStore Str Assign NameStore Str Assign NameStore TupleLoad NameLoad NameLoad Assign NameStore TupleLoad Str Str FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad NameLoad attr NameLoad keyword Str decorator_list FunctionDef arguments args NameParam defaults body Expr Str FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr NameLoad If NameLoad body Return Call NameLoad BinOpMod Str TupleLoad NameLoad NameLoad NameLoad Return NameLoad decorator_list Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str FunctionDef arguments args NameParam NameParam defaults body Return Call AttributeLoad NameLoad attr NameLoad decorator_list Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str FunctionDef arguments args NameParam NameParam defaults body Assign NameStore NameLoad Assign NameStore Call NameLoad NameLoad Str For NameStore NameLoad body Assign TupleStore NameStore NameStore NameStore Call AttributeLoad Call AttributeLoad NameLoad attr attr Str If BoolOpAnd CompareEq NameLoad NameLoad CompareEq NameLoad NameLoad body Assign NameStore NameLoad Break Expr Call AttributeLoad NameLoad attr Return NameLoad decorator_list Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str If CompareIs NameLoad NameLoad body Assign NameStore Call NameLoad Call AttributeLoad NameLoad attr Assign NameStore Call NameLoad BinOpMod Str TupleLoad NameLoad NameLoad NameLoad Assign NameStore BinOpMod Str TupleLoad NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call NameLoad NameLoad decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam defaults body Return BinOpMod Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad body Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr Str Num Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr If CompareNotEq AttributeLoad NameLoad attr Str body Raise Call NameLoad Str Assign AttributeStore NameLoad attr NameLoad Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Str Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Str Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Str Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Str Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Str Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Str Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Str Str Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Str Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Str Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Str Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Str If CompareNotIn AttributeLoad NameLoad attr NameLoad body Raise Call NameLoad Call AttributeLoad NameLoad attr BinOpMod Str AttributeLoad NameLoad attr Assign NameStore BoolOpAnd AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr If UnaryOpNot NameLoad body Raise Call NameLoad Call AttributeLoad NameLoad attr Str If AttributeLoad NameLoad attr body If CompareNotIn AttributeLoad NameLoad attr NameLoad body Raise Call NameLoad Call AttributeLoad NameLoad attr BinOpMod Str AttributeLoad NameLoad attr If UnaryOpNot BoolOpAnd AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Raise Call NameLoad Call AttributeLoad NameLoad attr Str orelse If BoolOpOr AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Raise Call NameLoad Call AttributeLoad NameLoad attr Str decorator_list FunctionDef arguments args NameParam defaults body Return BinOpMod Str AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str TryExcept body Assign TupleStore NameStore NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Str Num Assign TupleStore NameStore NameStore Call AttributeLoad Call NameLoad NameLoad NameLoad NameLoad attr Str Num Assign NameStore CompareEq NameLoad NameLoad If AttributeLoad NameLoad attr body Expr Call NameLoad BinOpMod Str NameLoad Return NameLoad handlers ExceptHandler type NameLoad body Pass Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults Num body Expr Str TryExcept body Assign TupleStore NameStore NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Str Num If CompareGt BinOpAdd Call NameLoad NameLoad NameLoad Call NameLoad Call AttributeLoad NameLoad attr body Return NameLoad handlers ExceptHandler type NameLoad body Pass If AttributeLoad NameLoad attr body Expr Call NameLoad Str Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults Str body Expr Str If BoolOpOr CompareIs AttributeLoad NameLoad attr NameLoad CompareEq AttributeLoad NameLoad attr Str body Assign NameStore BinOpMod Str TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr orelse If CompareEq AttributeLoad NameLoad attr Str body Assign NameStore BinOpMod Str TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr Call NameLoad NameLoad orelse Raise Call NameLoad Call AttributeLoad NameLoad attr Str Return Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults Str body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad If AttributeLoad NameLoad attr body Assign NameStore BinOpMod Str TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad orelse Assign NameStore BinOpMod Str TupleLoad AttributeLoad NameLoad attr NameLoad If CompareEq AttributeLoad NameLoad attr Str body Assign NameStore Call NameLoad BinOpMod Str TupleLoad NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore Call NameLoad BinOpMod Str TupleLoad NameLoad NameLoad Return NameLoad decorator_list decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults Str NameLoad NameLoad NameLoad body Expr Str If CompareNotIn NameLoad NameLoad body Raise Call NameLoad BinOpMod Str NameLoad If CompareNotIn NameLoad NameLoad body Raise Call NameLoad BinOpMod Str NameLoad If CompareIs NameLoad NameLoad body Assign NameStore Call NameLoad NameLoad NameLoad Assign NameStore BinOpMod Str TupleLoad NameLoad NameLoad NameLoad NameLoad If NameLoad body AugAssignAdd NameStore Str Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad body Expr Str Assign NameStore AttributeLoad AttributeLoad NameLoad attr attr Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Str Assign NameStore NameLoad If CompareIsNot NameLoad NameLoad body TryExcept body Assign NameStore Call NameLoad NameLoad AttributeLoad NameLoad attr keyword NameLoad handlers ExceptHandler type NameLoad body Raise Call AttributeLoad NameLoad attr Num Str If NameLoad body Expr Call NameLoad Call NameLoad NameLoad If Call AttributeLoad NameLoad attr NameLoad NameLoad body Assign NameStore Call NameLoad NameLoad AttributeLoad NameLoad attr If CompareIsNot NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad keyword AttributeLoad NameLoad attr If CompareEq NameLoad AttributeLoad NameLoad attr body If NameLoad body Expr Call NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr keyword Num If UnaryOpNot NameLoad body Assign AttributeStore NameLoad attr AttributeLoad NameLoad attr If NameLoad body Expr Call NameLoad BinOpMod Str AttributeLoad NameLoad attr Return Assign NameStore Call NameLoad NameLoad NameLoad keyword NameLoad If NameLoad body Expr Call NameLoad NameLoad Assign SubscriptStore AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr Index Str NameLoad Raise Call AttributeLoad NameLoad attr Num Str decorator_list
N/A N/A __doc__ An implementation of the server-side of HTTP Digest Access
Authentication, which is described in :rfc:`2617`.

Example usage, using the built-in get_ha1_dict_plain function which uses a dict
of plaintext passwords as the credentials store::

    userpassdict = {'alice' : '4x5istwelve'}
    get_ha1 = cherrypy.lib.auth_digest.get_ha1_dict_plain(userpassdict)
    digest_auth = {'tools.auth_digest.on': True,
                   'tools.auth_digest.realm': 'wonderland',
                   'tools.auth_digest.get_ha1': get_ha1,
                   'tools.auth_digest.key': 'a565c27146791cfb',
    }
    app_config = { '/' : digest_auth }
 N/A __author__ visteya N/A __date__ April 2009 N/A time cherrypy._cpcompat parse_http_list parse_keqv_list N/A cherrypy cherrypy._cpcompat md5 ntob N/A md5_hex N/A N/A N/A s N/A N/A N/A N/A md5 N/A ntob s hexdigest N/A qop_auth auth N/A qop_auth_int auth-int N/A valid_qops N/A qop_auth qop_auth_int N/A valid_algorithms N/A MD5 MD5-sess TRACE N/A N/A msg N/A N/A N/A N/A N/A cherrypy log msg context TOOLS.AUTH_DIGEST N/A get_ha1_dict_plain N/A N/A user_password_dict N/A N/A N/A Returns a get_ha1 function which obtains a plaintext password from a
    dictionary of the form: {username : password}.

    If you want a simple dictionary-based authentication scheme, with plaintext
    passwords, use get_ha1_dict_plain(my_userpass_dict) as the value for the
    get_ha1 argument to digest_auth().
     get_ha1 N/A N/A realm username N/A N/A N/A password N/A N/A user_password_dict get username N/A password N/A N/A N/A md5_hex N/A %s:%s:%s N/A username realm password N/A None N/A N/A get_ha1 N/A get_ha1_dict N/A N/A user_ha1_dict N/A N/A N/A Returns a get_ha1 function which obtains a HA1 password hash from a
    dictionary of the form: {username : HA1}.

    If you want a dictionary-based authentication scheme, but with
    pre-computed HA1 hashes instead of plain-text passwords, use
    get_ha1_dict(my_userha1_dict) as the value for the get_ha1
    argument to digest_auth().
     get_ha1 N/A N/A realm username N/A N/A N/A N/A N/A user_ha1_dict get user N/A N/A get_ha1 N/A get_ha1_file_htdigest N/A N/A filename N/A N/A N/A Returns a get_ha1 function which obtains a HA1 password hash from a
    flat file with lines of the same format as that produced by the Apache
    htdigest utility. For example, for realm 'wonderland', username 'alice',
    and password '4x5istwelve', the htdigest line would be::

        alice:wonderland:3238cdfe91a8b2ed8e39646921a02d4c

    If you want to use an Apache htdigest file as the credentials store,
    then use get_ha1_file_htdigest(my_htdigest_file) as the value for the
    get_ha1 argument to digest_auth().  It is recommended that the filename
    argument be an absolute path, to avoid problems.
     get_ha1 N/A N/A realm username N/A N/A N/A result None N/A f N/A open filename r N/A line f N/A N/A N/A u r ha1 N/A N/A N/A N/A line rstrip split : N/A N/A N/A u username N/A r realm N/A N/A result ha1 N/A N/A N/A N/A f close N/A result N/A N/A get_ha1 N/A synthesize_nonce N/A N/A s key timestamp N/A None N/A N/A Synthesize a nonce value which resists spoofing and can be checked for staleness.
    Returns a string suitable as the value for 'nonce' in the www-authenticate header.

    s
        A string related to the resource, such as the hostname of the server.

    key
        A secret string known only to the server.
    
    timestamp
        An integer seconds-since-the-epoch timestamp
    
     N/A N/A timestamp None N/A N/A timestamp N/A int N/A N/A time time N/A h N/A md5_hex N/A %s:%s:%s N/A timestamp s key N/A nonce N/A %s:%s N/A timestamp h N/A nonce N/A H N/A N/A s N/A N/A N/A The hash function H N/A N/A md5_hex s N/A HttpDigestAuthorization N/A object N/A N/A Class to parse a Digest Authorization header and perform re-calculation
    of the digest.
     errmsg N/A N/A self s N/A N/A N/A N/A Digest Authorization header: %s s N/A __init__ N/A N/A self auth_header http_method debug N/A False N/A N/A N/A self http_method http_method N/A N/A self debug debug N/A N/A scheme params N/A N/A auth_header split 1 N/A N/A self scheme N/A N/A scheme lower N/A N/A N/A self scheme digest N/A N/A N/A ValueError Authorization scheme is not "Digest" N/A N/A self auth_header auth_header N/A items N/A parse_http_list params N/A paramsd N/A parse_keqv_list items N/A N/A self realm N/A N/A paramsd get realm N/A N/A self username N/A N/A paramsd get username N/A N/A self nonce N/A N/A paramsd get nonce N/A N/A self uri N/A N/A paramsd get uri N/A N/A self method N/A N/A paramsd get method N/A N/A self response N/A N/A paramsd get response N/A N/A self algorithm N/A N/A paramsd get algorithm MD5 N/A N/A self cnonce N/A N/A paramsd get cnonce N/A N/A self opaque N/A N/A paramsd get opaque N/A N/A self qop N/A N/A paramsd get qop N/A N/A self nc N/A N/A paramsd get nc N/A N/A N/A self algorithm valid_algorithms N/A N/A N/A ValueError N/A N/A self errmsg N/A Unsupported value for algorithm: '%s' N/A self algorithm N/A has_reqd N/A N/A self username N/A self realm N/A self nonce N/A self uri N/A self response N/A N/A has_reqd N/A N/A N/A ValueError N/A N/A self errmsg Not all required parameters are present. N/A N/A self qop N/A N/A N/A N/A self qop valid_qops N/A N/A N/A ValueError N/A N/A self errmsg N/A Unsupported value for qop: '%s' N/A self qop N/A N/A N/A N/A self cnonce N/A self nc N/A N/A N/A ValueError N/A N/A self errmsg If qop is sent then cnonce and nc MUST be present N/A N/A N/A N/A self cnonce N/A self nc N/A N/A N/A ValueError N/A N/A self errmsg If qop is not sent, neither cnonce nor nc can be present N/A __str__ N/A N/A self N/A N/A N/A N/A authorization : %s N/A self auth_header N/A validate_nonce N/A N/A self s key N/A N/A N/A Validate the nonce.
        Returns True if nonce was generated by synthesize_nonce() and the timestamp
        is not spoofed, else returns False.

        s
            A string related to the resource, such as the hostname of the server.
            
        key
            A secret string known only to the server.
        
        Both s and key must be the same values which were used to synthesize the nonce
        we are trying to validate.
         N/A N/A N/A N/A timestamp hashpart N/A N/A N/A self nonce split : 1 N/A N/A s_timestamp s_hashpart N/A N/A N/A synthesize_nonce s key timestamp split : 1 N/A is_valid N/A s_hashpart hashpart N/A N/A self debug N/A N/A N/A TRACE N/A validate_nonce: %s is_valid N/A is_valid N/A N/A N/A ValueError N/A N/A N/A False N/A is_nonce_stale N/A N/A self max_age_seconds N/A 600 N/A N/A Returns True if a validated nonce is stale. The nonce contains a
        timestamp in plaintext and also a secure hash of the timestamp. You should
        first validate the nonce to ensure the plaintext timestamp is not spoofed.
         N/A N/A N/A N/A timestamp hashpart N/A N/A N/A self nonce split : 1 N/A N/A N/A N/A int timestamp max_age_seconds N/A int N/A N/A time time N/A N/A False N/A N/A N/A ValueError N/A N/A N/A N/A self debug N/A N/A N/A TRACE nonce is stale N/A True N/A HA2 N/A N/A self entity_body N/A N/A N/A Returns the H(A2) string. See :rfc:`2617` section 3.2.2.3. N/A N/A N/A N/A self qop None N/A N/A self qop auth N/A N/A a2 N/A %s:%s N/A N/A self http_method N/A self uri N/A N/A N/A N/A self qop auth-int N/A N/A a2 N/A %s:%s:%s N/A N/A self http_method N/A self uri N/A H entity_body N/A N/A N/A ValueError N/A N/A self errmsg Unrecognized value for qop! N/A N/A H a2 N/A request_digest N/A N/A self ha1 entity_body N/A N/A N/A Calculates the Request-Digest. See :rfc:`2617` section 3.2.2.1.

        ha1
            The HA1 string obtained from the credentials store.

        entity_body
            If 'qop' is set to 'auth-int', then A2 includes a hash
            of the "entity body".  The entity body is the part of the
            message which follows the HTTP headers. See :rfc:`2617` section
            4.3.  This refers to the entity the user agent sent in the request which
            has the Authorization header. Typically GET requests don't have an entity,
            and POST requests do.
        
         N/A ha2 N/A N/A self HA2 entity_body N/A N/A self qop N/A N/A req N/A %s:%s:%s:%s:%s N/A N/A self nonce N/A self nc N/A self cnonce N/A self qop ha2 N/A N/A req N/A %s:%s N/A N/A self nonce ha2 N/A N/A N/A self algorithm MD5-sess N/A N/A ha1 N/A H N/A %s:%s:%s N/A ha1 N/A self nonce N/A self cnonce N/A digest N/A H N/A %s:%s N/A ha1 req N/A digest N/A N/A www_authenticate N/A N/A realm key algorithm nonce qop stale N/A MD5 None qop_auth False N/A N/A Constructs a WWW-Authenticate header for Digest authentication. N/A N/A qop valid_qops N/A N/A N/A ValueError N/A Unsupported value for qop: '%s' qop N/A N/A algorithm valid_algorithms N/A N/A N/A ValueError N/A Unsupported value for algorithm: '%s' algorithm N/A N/A nonce None N/A N/A nonce N/A synthesize_nonce realm key N/A s N/A Digest realm="%s", nonce="%s", algorithm="%s", qop="%s" N/A realm nonce algorithm qop N/A stale N/A N/A s , stale="true" N/A s N/A digest_auth N/A N/A realm get_ha1 key debug N/A False N/A N/A A CherryPy tool which hooks at before_handler to perform
    HTTP Digest Access Authentication, as specified in :rfc:`2617`.
    
    If the request has an 'authorization' header with a 'Digest' scheme, this
    tool authenticates the credentials supplied in that header.  If
    the request has no 'authorization' header, or if it does but the scheme is
    not "Digest", or if authentication fails, the tool sends a 401 response with
    a 'WWW-Authenticate' Digest header.
    
    realm
        A string containing the authentication realm.
    
    get_ha1
        A callable which looks up a username in a credentials store
        and returns the HA1 string, which is defined in the RFC to be
        MD5(username : realm : password).  The function's signature is:
        ``get_ha1(realm, username)``
        where username is obtained from the request's 'authorization' header.
        If username is not found in the credentials store, get_ha1() returns
        None.
    
    key
        A secret string known only to the server, used in the synthesis of nonces.
    
     N/A request N/A N/A cherrypy serving request N/A auth_header N/A N/A N/A request headers get authorization N/A nonce_is_stale False N/A N/A auth_header None N/A N/A N/A N/A auth N/A HttpDigestAuthorization auth_header N/A request method debug debug N/A N/A N/A ValueError N/A N/A N/A N/A cherrypy HTTPError 400 The Authorization header could not be parsed. N/A debug N/A N/A N/A TRACE N/A str auth N/A N/A N/A auth validate_nonce realm key N/A N/A ha1 N/A get_ha1 realm N/A auth username N/A N/A ha1 None N/A N/A digest N/A N/A auth request_digest ha1 entity_body N/A request body N/A N/A digest N/A auth response N/A N/A debug N/A N/A N/A TRACE digest matches auth.response N/A nonce_is_stale N/A N/A auth is_nonce_stale max_age_seconds 600 N/A N/A nonce_is_stale N/A N/A N/A request login N/A auth username N/A debug N/A N/A N/A TRACE N/A authentication of %s successful N/A auth username N/A N/A header N/A www_authenticate realm key stale nonce_is_stale N/A debug N/A N/A N/A TRACE header N/A N/A N/A N/A N/A cherrypy serving response headers N/A WWW-Authenticate header N/A N/A N/A cherrypy HTTPError 401 You are not authorized to access that resource N/A