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

Type Consumer

object --+
         |
        Consumer


An OpenID consumer implementation that performs discovery and does session management.
Method Summary
  __init__(self, session, store, consumer_class)
Initialize a Consumer instance.
AuthRequest begin(self, user_url, anonymous)
Start the OpenID authentication process.
AuthRequest beginWithoutDiscovery(self, service, anonymous)
Start OpenID verification without doing OpenID server discovery.
  complete(self, query, return_to)
Called to interpret the server's response to an OpenID request.
  setAssociationPreference(self, association_preferences)
Set the order in which association types/sessions should be attempted.
Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Instance Variable Summary
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.

Class Variable Summary
str session_key_prefix: A string that is prepended to session keys to ensure that they are unique.

Instance Method Details

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

Initialize a Consumer instance.

You should create a new instance of the Consumer object with every HTTP request that handles OpenID transactions.
Parameters:
session - See the session instance variable
store - an object that implements the interface in openid.store.interface.OpenIDStore. Several implementations are provided, to cover common database environments.
           (type=openid.store.interface.OpenIDStore)
Overrides:
__builtin__.object.__init__
See Also:
openid.store.interface, openid.store

begin(self, user_url, anonymous=False)

Start the OpenID authentication process. See steps 1-2 in the overview at the top of this file.
Parameters:
user_url - 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.
           (type=unicode)
anonymous - 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."
           (type=bool)
Returns:
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.
           (type=AuthRequest)
Raises:
openid.consumer.discover.DiscoveryFailure - when I fail to find an OpenID server for this URL. If the yadis package is available, openid.consumer.discover.DiscoveryFailure is an alias for yadis.discover.DiscoveryFailure.

beginWithoutDiscovery(self, service, anonymous=False)

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:
service - an OpenID service endpoint descriptor. This object and factories for it are found in the openid.consumer.discover module.
           (type=OpenIDServiceEndpoint)
Returns:
an OpenID authentication request object.
           (type=AuthRequest)
See Also:
Openid.consumer.consumer.Consumer.begin, openid.consumer.discover

complete(self, query, return_to)

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.
return_to - The return 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.
See Also:
SuccessResponse, CancelResponse, SetupNeededResponse, FailureResponse

setAssociationPreference(self, association_preferences)

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 - 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.
           (type=[(str, str)])
Returns:
None

See Also: openid.association.SessionNegotiator


Instance Variable Details

consumer

an instance of an object implementing the OpenID protocol, but doing no discovery or session management.
Type:
GenericConsumer

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.

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.
Type:
str
Value:
'_openid_consumer_'                                                    

Generated by Epydoc 2.1 on Wed Nov 14 17:47:21 2007 http://epydoc.sf.net