Package openid :: Package consumer :: Module consumer :: Class Consumer
[frames] | no frames]

Class Consumer

source code

object --+
         |
        Consumer

An OpenID consumer implementation that performs discovery and does session management.

Instance Methods
 
__init__(self, session, store, consumer_class=None)
Initialize a Consumer instance.
source code
AuthRequest
begin(self, user_url, anonymous=False)
Start the OpenID authentication process.
source code
AuthRequest
beginWithoutDiscovery(self, service, anonymous=False)
Start OpenID verification without doing OpenID server discovery.
source code
 
complete(self, query, current_url)
Called to interpret the server's response to an OpenID request.
source code
 
setAssociationPreference(self, association_preferences)
Set the order in which association types/sessions should be attempted.
source code

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

Class Variables
  session_key_prefix = '_openid_consumer_'
A string that is prepended to session keys to ensure that they are unique.
Instance Variables
GenericConsumer consumer
an instance of an object implementing the OpenID protocol, but doing no discovery or session management.
  session
A dictionary-like object representing the user's session data.
Properties

Inherited from object: __class__

Method Details

__init__(self, session, store, consumer_class=None)
(Constructor)

source code 

Initialize a Consumer instance.

You should create a new instance of the Consumer object with every HTTP request that handles OpenID transactions.

Parameters:
Overrides: object.__init__

begin(self, user_url, anonymous=False)

source code 

Start the OpenID authentication process. See steps 1-2 in the overview at the top of this file.

Parameters:
  • user_url (unicode) - Identity URL given by the user. This method performs a textual transformation of the URL to try and make sure it is normalized. For example, a user_url of example.com will be normalized to http://example.com/ normalizing and resolving any redirects the server might issue.
  • anonymous (bool) - Whether to make an anonymous request of the OpenID provider. Such a request does not ask for an authorization assertion for an OpenID identifier, but may be used with extensions to pass other data. e.g. "I don't care who you are, but I'd like to know your time zone."
Returns: AuthRequest
An object containing the discovered information will be returned, with a method for building a redirect URL to the server, as described in step 3 of the overview. This object may also be used to add extension arguments to the request, using its addExtensionArg method.
Raises:

beginWithoutDiscovery(self, service, anonymous=False)

source code 

Start OpenID verification without doing OpenID server discovery. This method is used internally by Consumer.begin after discovery is performed, and exists to provide an interface for library users needing to perform their own discovery.

Parameters:
Returns: AuthRequest
an OpenID authentication request object.
See Also:
Openid.consumer.consumer.Consumer.begin, openid.consumer.discover

complete(self, query, current_url)

source code 

Called to interpret the server's response to an OpenID request. It is called in step 4 of the flow described in the consumer overview.

Parameters:
  • query - A dictionary of the query parameters for this HTTP request.
  • current_url - The URL used to invoke the application. Extract the URL from your application's web request framework and specify it here to have it checked against the openid.return_to value in the response. If the return_to URL check fails, the status of the completion will be FAILURE.
Returns:
a subclass of Response. The type of response is indicated by the status attribute, which will be one of SUCCESS, CANCEL, FAILURE, or SETUP_NEEDED.

setAssociationPreference(self, association_preferences)

source code 

Set the order in which association types/sessions should be attempted. For instance, to only allow HMAC-SHA256 associations created with a DH-SHA256 association session:

>>> consumer.setAssociationPreference([('HMAC-SHA256', 'DH-SHA256')])

Any association type/association type pair that is not in this list will not be attempted at all.

Parameters:
  • association_preferences ([(str, str)]) - The list of allowed (association type, association session type) pairs that should be allowed for this consumer to use, in order from most preferred to least preferred.
Returns:
None

Class Variable Details

session_key_prefix

A string that is prepended to session keys to ensure that they are unique. This variable may be changed to suit your application.
Value:
'_openid_consumer_'

Instance Variable Details

session

A dictionary-like object representing the user's session data. This is used for keeping state of the OpenID transaction when the user is redirected to the server.