Package openid :: Package consumer :: Module consumer :: Class GenericConsumer
[hide private]
[frames] | no frames]

Class GenericConsumer

source code

object --+
         |
        GenericConsumer
Known Subclasses:

This is the implementation of the common logic for OpenID consumers. It is unaware of the application in which it is running.

Instance Methods [hide private]
 
__init__(self, store)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
begin(self, service_endpoint)
Create an AuthRequest object for the specified service_endpoint.
source code
 
complete(self, message, endpoint, return_to)
Process the OpenID message, using the specified endpoint and return_to URL as context.
source code
 
_complete_cancel(self, message, endpoint, _) source code
 
_complete_error(self, message, endpoint, _) source code
 
_complete_setup_needed(self, message, endpoint, _) source code
 
_complete_id_res(self, message, endpoint, return_to) source code
 
_completeInvalid(self, message, endpoint, _) source code
 
_checkReturnTo(self, message, return_to)
Check an OpenID message and its openid.return_to value against a return_to URL from an application.
source code
 
_checkSetupNeeded(self, message)
Check an id_res message to see if it is a checkid_immediate cancel response.
source code
Response
_doIdRes(self, message, endpoint, return_to)
Handle id_res responses that are not cancellations of immediate mode requests.
source code
 
_idResGetNonceOpenID1(self, message, endpoint)
Extract the nonce from an OpenID 1 response.
source code
 
_idResCheckNonce(self, message, endpoint) source code
 
_idResCheckSignature(self, message, server_url) source code
 
_idResCheckForFields(self, message) source code
 
_verifyDiscoveryResults(self, resp_msg, endpoint=None)
Extract the information from an OpenID assertion message and verify it against the original
source code
 
_verifyDiscoveryResultsOpenID2(self, resp_msg, endpoint) source code
 
_verifyDiscoveryResultsOpenID1(self, resp_msg, endpoint) source code
NoneType
_verifyDiscoverySingle(self, endpoint, to_match)
Verify that the given endpoint matches the information extracted from the OpenID assertion, and raise an exception if there is a mismatch.
source code
openid.consumer.discover.OpenIDServiceEndpoint
_discoverAndVerify(self, claimed_id, to_match_endpoints)
Given an endpoint object created from the information in an OpenID response, perform discovery and verify the discovery results, returning the matching endpoint that is the result of doing that discovery.
source code
 
_verifyDiscoveredServices(self, claimed_id, services, to_match_endpoints)
See @_discoverAndVerify
source code
bool
_checkAuth(self, message, server_url)
Make a check_authentication request to verify this message.
source code
 
_createCheckAuthRequest(self, message)
Generate a check_authentication request message given an id_res message.
source code
 
_processCheckAuthResponse(self, response, server_url)
Process the response message from a check_authentication request, invalidating associations if requested.
source code
openid.association.Association or NoneType
_getAssociation(self, endpoint)
Get an association for the endpoint's server_url.
source code
openid.association.Association
_negotiateAssociation(self, endpoint)
Make association requests to the server, attempting to create a new association.
source code
tuple or None
_extractSupportedAssociationType(self, server_error, endpoint, assoc_type)
Handle ServerErrors resulting from association requests.
source code
 
_requestAssociation(self, endpoint, assoc_type, session_type)
Make and process one association request to this endpoint's OP endpoint URL.
source code
(association session type (depends on session_type), openid.message.Message)
_createAssociateRequest(self, endpoint, assoc_type, session_type)
Create an association request for the given assoc_type and session_type.
source code
str
_getOpenID1SessionType(self, assoc_response)
Given an association response message, extract the OpenID 1.X session type.
source code
openid.association.Association
_extractAssociation(self, assoc_response, assoc_session)
Attempt to extract an association from the response, given the association response message and the established association session.
source code

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

Static Methods [hide private]
 
_discover(identifier) source code
openid.message.Message
_makeKVPost(request_message, server_url)
Make a Direct Request to an OpenID Provider and return the result as a Message object.
source code
 
_verifyReturnToArgs(query)
Verify that the arguments in the return_to URL are present in this response.
source code
Class Variables [hide private]
  openid1_nonce_query_arg_name = 'janrain_nonce'
  openid1_return_to_identifier_name = 'openid1_claimed_id'
  session_types = {'DH-SHA1': <class 'openid.consumer.consumer.D...
Instance Variables [hide private]
openid.association.SessionNegotiator negotiator
An object that controls the kind of associations that the consumer makes.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, store)
(Constructor)

source code 

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

Overrides: object.__init__
(inherited documentation)

begin(self, service_endpoint)

source code 

Create an AuthRequest object for the specified service_endpoint. This method will create an association if necessary.

complete(self, message, endpoint, return_to)

source code 

Process the OpenID message, using the specified endpoint and return_to URL as context. This method will handle any OpenID message that is sent to the return_to URL.

_checkReturnTo(self, message, return_to)

source code 

Check an OpenID message and its openid.return_to value against a return_to URL from an application. Return True on success, False on failure.

_makeKVPost(request_message, server_url)
Static Method

source code 

Make a Direct Request to an OpenID Provider and return the result as a Message object.

Returns: openid.message.Message
Raises:

_checkSetupNeeded(self, message)

source code 

Check an id_res message to see if it is a checkid_immediate cancel response.

Raises:

_doIdRes(self, message, endpoint, return_to)

source code 

Handle id_res responses that are not cancellations of immediate mode requests.

Parameters:
  • message - the response paramaters.
  • endpoint - the discovered endpoint object. May be None.
Returns: Response
Raises:
  • ProtocolError - If the message contents are not well-formed according to the OpenID specification. This includes missing fields or not signing fields that should be signed.
  • DiscoveryFailure - If the subject of the id_res message does not match the supplied endpoint, and discovery on the identifier in the message fails (this should only happen when using OpenID 2)

_idResGetNonceOpenID1(self, message, endpoint)

source code 

Extract the nonce from an OpenID 1 response. Return the nonce from the BARE_NS since we independently check the return_to arguments are the same as those in the response message.

See the openid1_nonce_query_arg_name class variable

Returns:
The nonce as a string or None

_verifyDiscoveryResults(self, resp_msg, endpoint=None)

source code 

Extract the information from an OpenID assertion message and verify it against the original

Parameters:
  • endpoint - The endpoint that resulted from doing discovery
  • resp_msg - The id_res message object
Returns:
the verified endpoint

_verifyDiscoverySingle(self, endpoint, to_match)

source code 

Verify that the given endpoint matches the information extracted from the OpenID assertion, and raise an exception if there is a mismatch.

Parameters:
  • to_match (openid.consumer.discover.OpenIDServiceEndpoint)
  • endpoint (openid.consumer.discover.OpenIDServiceEndpoint)
Returns: NoneType
Raises:
  • ProtocolError - when the endpoint does not match the discovered information.

_discoverAndVerify(self, claimed_id, to_match_endpoints)

source code 

Given an endpoint object created from the information in an OpenID response, perform discovery and verify the discovery results, returning the matching endpoint that is the result of doing that discovery.

Parameters:
  • to_match (openid.consumer.discover.OpenIDServiceEndpoint) - The endpoint whose information we're confirming
Returns: openid.consumer.discover.OpenIDServiceEndpoint
The result of performing discovery on the claimed identifier in `to_match'
Raises:

_checkAuth(self, message, server_url)

source code 

Make a check_authentication request to verify this message.

Returns: bool
True if the request is valid.

_getAssociation(self, endpoint)

source code 

Get an association for the endpoint's server_url.

First try seeing if we have a good association in the store. If we do not, then attempt to negotiate an association with the server.

If we negotiate a good association, it will get stored.

Returns: openid.association.Association or NoneType
A valid association for the endpoint's server_url or None

_negotiateAssociation(self, endpoint)

source code 

Make association requests to the server, attempting to create a new association.

Returns: openid.association.Association
a new association object

_extractSupportedAssociationType(self, server_error, endpoint, assoc_type)

source code 

Handle ServerErrors resulting from association requests.

Returns: tuple or None
If server replied with an unsupported-type error, return a tuple of supported association_type, session_type. Otherwise logs the error and returns None.

_requestAssociation(self, endpoint, assoc_type, session_type)

source code 

Make and process one association request to this endpoint's OP endpoint URL.

Returns:
An association object or None if the association processing failed.
Raises:
  • ServerError - when the remote OpenID server returns an error.

_createAssociateRequest(self, endpoint, assoc_type, session_type)

source code 

Create an association request for the given assoc_type and session_type.

Parameters:
  • endpoint - The endpoint whose server_url will be queried. The important bit about the endpoint is whether it's in compatiblity mode (OpenID 1.1)
  • assoc_type (str) - The association type that the request should ask for.
  • session_type (str) - The session type that should be used in the association request. The session_type is used to create an association session object, and that session object is asked for any additional fields that it needs to add to the request.
Returns: (association session type (depends on session_type), openid.message.Message)
a pair of the association session object and the request message that will be sent to the server.

_getOpenID1SessionType(self, assoc_response)

source code 

Given an association response message, extract the OpenID 1.X session type.

This function mostly takes care of the 'no-encryption' default behavior in OpenID 1.

If the association type is plain-text, this function will return 'no-encryption'

Returns: str
The association type for this message
Raises:
  • KeyError - when the session_type field is absent.

_extractAssociation(self, assoc_response, assoc_session)

source code 

Attempt to extract an association from the response, given the association response message and the established association session.

Parameters:
  • assoc_response (openid.message.Message) - The association response message from the server
  • assoc_session (depends on the session type of the request) - The association session object that was used when making the request
Returns: openid.association.Association
Raises:
  • ProtocolError - when data is malformed
  • KeyError - when a field is missing

Class Variable Details [hide private]

session_types

Value:
{'DH-SHA1': <class 'openid.consumer.consumer.DiffieHellmanSHA1Consumer\
Session'>,
 'DH-SHA256': <class 'openid.consumer.consumer.DiffieHellmanSHA256Cons\
umerSession'>,
 'no-encryption': <class 'openid.consumer.consumer.PlainTextConsumerSe\
ssion'>}

Instance Variable Details [hide private]

negotiator

An object that controls the kind of associations that the consumer makes. It defaults to openid.association.default_negotiator. Assign a different negotiator to it if you have specific requirements for how associations are made.
Type:
openid.association.SessionNegotiator