Package wsgitools :: Module digest :: Class AuthDigestMiddleware
[hide private]
[frames] | no frames]

Class AuthDigestMiddleware

source code


Middleware partly implementing RFC2617. (md5-sess was omited) Upon successful authentication the environ dict will be extended by a REMOTE_USER key before being passed to the wrapped application.

Instance Methods [hide private]
 
__init__(self, app, gentoken, maxage=300, maxuses=5, store=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
{str: object}
authenticate(self, auth, environ)
Try to authenticate a request.
source code
 
auth_response(self, credentials, reqmethod)
internal method generating authentication tokens
source code
(str, str)
www_authenticate(self, exception)
Generates a WWW-Authenticate header.
source code

Inherited from authentication.AuthenticationMiddleware: __call__, authorization_required

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
str authorization_method = 'digest'
the implemented Authorization method.
  algorithms = {'md5': <__builtin__.function object>}
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, app, gentoken, maxage=300, maxuses=5, store=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • app - is the wsgi application to be served with authentication.
  • gentoken (str -> (str or None)) - has to have the same functionality and interface as the AuthTokenGenerator class.
  • maxage (int) - deprecated, see MemoryNonceStore or StatelessNonceStore and pass an instance to store
  • maxuses (int) - deprecated, see MemoryNonceStore and pass an instance to store
  • store (NonceStoreBase) - a nonce storage implementation object. Usage of this parameter will override maxage and maxuses.
Overrides: object.__init__

authenticate(self, auth, environ)

source code 

Try to authenticate a request. The Authorization header is examined and checked agains the authorization_method before being passed to this method. This method must either raise an AuthenticationRequired instance or return a dictionary explaining what was successfully authenticated.

Parameters:
  • auth - is the part of the Authorization header after the method
  • environ - is the environment passed with a WSGI request
Returns: {str: object}
a dictionary that provides a key "user" listing the authenticated username as a string. It may also provide the key "outheaders" with a [(str, str)] value to extend the response headers.
Raises:
Overrides: authentication.AuthenticationMiddleware.authenticate
(inherited documentation)

auth_response(self, credentials, reqmethod)

source code 

internal method generating authentication tokens

Raises:

www_authenticate(self, exception)

source code 

Generates a WWW-Authenticate header. Subclasses must implement this method.

Parameters:
  • exception - reason for generating the header
Returns: (str, str)
the header as (part_before_colon, part_after_colon)
Overrides: authentication.AuthenticationMiddleware.www_authenticate
(inherited documentation)