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

Class OpenIDStore

source code

object --+
         |
        OpenIDStore
Known Subclasses:

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.


Change Log: Version 2.0 removed the storeNonce, getAuthKey, and isDumb methods, and changed the behavior of the useNonce method to support one-way nonces. It added cleanupNonces, cleanupAssociations, and cleanup.

Instance Methods
NoneType
storeAssociation(self, server_url, association)
This method puts a Association object into storage, retrievable by server URL and handle.
source code
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.
source code
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.
source code
bool
useNonce(self, server_url, timestamp, salt)
Called when using a nonce.
source code
 
cleanup(self)
Shortcut for cleanupNonces(), cleanupAssociations().
source code
int
cleanupAssociations(self)
Remove expired associations from the store.
source code
int
cleanupNonces(self)
Remove expired nonces from the store.
source code

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

Properties

Inherited from object: __class__

Method Details

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 most recently issued.

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.

useNonce(self, server_url, timestamp, salt)

source code 

Called when using a nonce.

This method should return True if the nonce has not been used before, and store it for a while to make sure nobody tries to use the same value again. If the nonce has already been used or the timestamp is not current, return False.

You may use openid.store.nonce.SKEW for your timestamp window.

Parameters:
  • server_url (str) - The URL of the server from which the nonce originated.
  • timestamp (int) - The time that the nonce was created (to the nearest second), in seconds since January 1 1970 UTC.
  • salt (str) - A random string that makes two nonces from the same server issued during the same second unique.
Returns: bool
Whether or not the nonce was valid.

Change Log: In earlier versions, round-trip nonces were used and a nonce was only valid if it had been previously stored with storeNonce. Version 2.0 uses one-way nonces, requiring a different implementation here that does not depend on a storeNonce call. (storeNonce is no longer part of the interface.)

cleanup(self)

source code 

Shortcut for cleanupNonces(), cleanupAssociations().

This method is not called in the normal operation of the library. It provides a way for store admins to keep their storage from filling up with expired data.

cleanupAssociations(self)

source code 

Remove expired associations from the store.

This method is not called in the normal operation of the library. It provides a way for store admins to keep their storage from filling up with expired data.

Returns: int
the number of associations expired.

cleanupNonces(self)

source code 

Remove expired nonces from the store.

Discards any nonce from storage that is old enough that its timestamp would not pass useNonce.

This method is not called in the normal operation of the library. It provides a way for store admins to keep their storage from filling up with expired data.

Returns: int
the number of nonces expired.