Package wsgitools :: Module authentication :: Class AuthenticationMiddleware
[hide private]
[frames] | no frames]

Class AuthenticationMiddleware

source code


Base class for HTTP authorization schemes.

Instance Methods [hide private]
 
__call__(self, environ, start_response)
wsgi interface
source code
 
__init__(self, app)
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
 
authorization_required(self, environ, start_response, exception)
Generate an error page after failed authentication.
source code
(str, str)
www_authenticate(self, exception)
Generates a WWW-Authenticate header.
source code

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

Class Variables [hide private]
str authorization_method = None
the implemented Authorization method.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__call__(self, environ, start_response)
(Call operator)

source code 

wsgi interface

Parameters:
  • environ ({str: object})

__init__(self, app)
(Constructor)

source code 

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

Parameters:
  • app - is a WSGI application.
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 (str) - is the part of the Authorization header after the method
  • environ ({str: object}) - 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:

authorization_required(self, environ, start_response, exception)

source code 

Generate an error page after failed authentication. Apart from the exception parameter, this method behaves like a WSGI application.

Parameters:

www_authenticate(self, exception)

source code 

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

Parameters:
Returns: (str, str)
the header as (part_before_colon, part_after_colon)

Class Variable Details [hide private]

authorization_method

the implemented Authorization method. It will be verified against Authorization headers. Subclasses must define this attribute.
Type:
str
Value:
None