Package openid :: Package store :: Module filestore :: Class FileOpenIDStore
[frames] | no frames]

Class FileOpenIDStore

source code

           object --+    
                    |    
interface.OpenIDStore --+
                        |
                       FileOpenIDStore

This is a filesystem-based store for OpenID associations and nonces. This store should be safe for use in concurrent systems on both windows and unix (excluding NFS filesystems). There are a couple race conditions in the system, but those failure cases have been set up in such a way that the worst-case behavior is someone having to try to log in a second time.

Most of the methods of this class are implementation details. People wishing to just use this store need only pay attention to the __init__ method.

Methods of this object can raise OSError if unexpected filesystem conditions, such as bad permissions or missing directories, occur.

Instance Methods
 
__init__(self, directory)
Initializes a new FileOpenIDStore.
source code
 
getAssociationFilename(self, server_url, handle)
Create a unique filename for a given server url and handle.
source code
NoneType
storeAssociation(self, server_url, association)
Store an association in the association directory.
source code
Association or NoneType
getAssociation(self, server_url, handle=None)
Retrieve an association.
source code
bool or int
removeAssociation(self, server_url, handle)
Remove an association if it exists.
source code
bool
useNonce(self, server_url, timestamp, salt)
Return whether this nonce is valid.
source code
 
cleanup(self)
Remove expired entries from the database.
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__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties

Inherited from object: __class__

Method Details

__init__(self, directory)
(Constructor)

source code 

Initializes a new FileOpenIDStore. This initializes the nonce and association directories, which are subdirectories of the directory passed in.

Parameters:
  • directory (str) - This is the directory to put the store directories in.
Overrides: object.__init__

getAssociationFilename(self, server_url, handle)

source code 

Create a unique filename for a given server url and handle. This implementation does not assume anything about the format of the handle. The filename that is returned will contain the domain name from the server URL for ease of human inspection of the data directory.

(str, str) -> str

storeAssociation(self, server_url, association)

source code 

Store an association in the association directory.

(str, Association) -> NoneType

Parameters:
  • server_url - 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 - The Association to store.
Returns: NoneType
None
Overrides: interface.OpenIDStore.storeAssociation

getAssociation(self, server_url, handle=None)

source code 

Retrieve an association. If no handle is specified, return the association with the latest expiration.

(str, str or NoneType) -> Association or NoneType

Parameters:
  • server_url - 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 - 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.
Overrides: interface.OpenIDStore.getAssociation

removeAssociation(self, server_url, handle)

source code 

Remove an association if it exists. Do nothing if it does not.

(str, str) -> bool

Parameters:
  • server_url - 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 - 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.
Overrides: interface.OpenIDStore.removeAssociation

useNonce(self, server_url, timestamp, salt)

source code 

Return whether this nonce is valid.

str -> bool

Parameters:
  • server_url - The URL of the server from which the nonce originated.
  • timestamp - The time that the nonce was created (to the nearest second), in seconds since January 1 1970 UTC.
  • salt - 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.
Overrides: interface.OpenIDStore.useNonce

cleanup(self)

source code 

Remove expired entries from the database. This is potentially expensive, so only run when it is acceptable to take time.

() -> NoneType

Overrides: interface.OpenIDStore.cleanup

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.
Overrides: interface.OpenIDStore.cleanupAssociations
(inherited documentation)

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.
Overrides: interface.OpenIDStore.cleanupNonces
(inherited documentation)