Package openid :: Package store :: Module interface :: Class OpenIDStore
[frames] | no frames]

Class OpenIDStore

source code

object --+
         |
        OpenIDStore
Known Subclasses:
filestore.FileOpenIDStore, dumbstore.DumbStore, sqlstore.SQLStore

This is the interface for the store objects the OpenID library uses. It is a single class that provides all of the persistence mechanisms that the OpenID library needs, for both servers and consumers.

Instance Methods [hide private]
NoneType storeAssociation(self, server_url, association)
This method puts a Association object into storage, retrievable by server URL and handle.
Association or NoneType getAssociation(self, server_url, handle=None)
This method returns an Association object from storage that matches the server URL and, if specified, handle.
bool or int removeAssociation(self, server_url, handle)
This method removes the matching association if it's found, and returns whether the association was removed or not.
NoneType storeNonce(self, nonce)
Stores a nonce.
bool or int useNonce(self, nonce)
This method is called when the library is attempting to use a nonce.
str getAuthKey(self)
This method returns a key used to sign the tokens, to ensure that they haven't been tampered with in transit.
bool isDumb(self)
This method must return True if the store is a dumb-mode-style store.

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


Class Variables [hide private]
  AUTH_KEY_LEN = 20
The length of the auth key that should be returned by the getAuthKey method.

Properties [hide private]

Inherited from object: __class__


Method Details [hide private]

storeAssociation(self, server_url, association)

source code 

This method puts a Association object into storage, retrievable by server URL and handle.
Parameters:
  • server_url (str) - The URL of the identity server that this association is with. Because of the way the server portion of the library uses this interface, don't assume there are any limitations on the character set of the input string. In particular, expect to see unescaped non-url-safe characters in the server_url field.
  • association (Association) - The Association to store.
Returns: NoneType
None

getAssociation(self, server_url, handle=None)

source code 

This method returns an Association object from storage that matches the server URL and, if specified, handle. It returns None if no such association is found or if the matching association is expired.

If no handle is specified, the store may return any association which matches the server URL. If multiple associations are valid, the recommended return value for this method is the one that will remain valid for the longest duration.

This method is allowed (and encouraged) to garbage collect expired associations when found. This method must not return expired associations.
Parameters:
  • server_url (str) - The URL of the identity server to get the association for. Because of the way the server portion of the library uses this interface, don't assume there are any limitations on the character set of the input string. In particular, expect to see unescaped non-url-safe characters in the server_url field.
  • handle (str or NoneType) - This optional parameter is the handle of the specific association to get. If no specific handle is provided, any valid association matching the server URL is returned.
Returns: Association or NoneType
The Association for the given identity server.

removeAssociation(self, server_url, handle)

source code 

This method removes the matching association if it's found, and returns whether the association was removed or not.
Parameters:
  • server_url (str) - The URL of the identity server the association to remove belongs to. Because of the way the server portion of the library uses this interface, don't assume there are any limitations on the character set of the input string. In particular, expect to see unescaped non-url-safe characters in the server_url field.
  • handle (str) - This is the handle of the association to remove. If there isn't an association found that matches both the given URL and handle, then there was no matching handle found.
Returns: bool or int
Returns whether or not the given association existed.

storeNonce(self, nonce)

source code 

Stores a nonce. This is used by the consumer to prevent replay attacks.
Parameters:
  • nonce (str) - The nonce to store.
Returns: NoneType
None

useNonce(self, nonce)

source code 

This method is called when the library is attempting to use a nonce. If the nonce is in the store, this method removes it and returns a value which evaluates as true. Otherwise it returns a value which evaluates as false.

This method is allowed and encouraged to treat nonces older than some period (a very conservative window would be 6 hours, for example) as no longer existing, and return False and remove them.
Parameters:
  • nonce (str) - The nonce to use.
Returns: bool or int
Whether or not the nonce was valid.

getAuthKey(self)

source code 

This method returns a key used to sign the tokens, to ensure that they haven't been tampered with in transit. It should return the same key every time it is called. The key returned should be AUTH_KEY_LEN bytes long.
Returns: str
The key. It should be AUTH_KEY_LEN bytes in length, and use the full range of byte values. That is, it should be treated as a lump of binary data stored in a str instance.

isDumb(self)

source code 

This method must return True if the store is a dumb-mode-style store. Unlike all other methods in this class, this one provides a default implementation, which returns False.

In general, any custom subclass of OpenIDStore won't override this method, as custom subclasses are only likely to be created when the store is fully functional.
Returns: bool
True if the store works fully, False if the consumer will have to use dumb mode to use this store.

Class Variable Details [hide private]

AUTH_KEY_LEN


The length of the auth key that should be returned by the getAuthKey method.
Value:
20