Auth_OpenID_FileStore
extends Auth_OpenID_OpenIDStore
in package
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 constructor.
Table of Contents
- $active : mixed
- $association_dir : mixed
- $directory : mixed
- $max_nonce_age : mixed
- $nonce_dir : mixed
- $temp_dir : mixed
- __construct() : mixed
- Initializes a new {@link Auth_OpenID_FileStore}. This initializes the nonce and association directories, which are subdirectories of the directory passed in.
- _allAssocs() : mixed
- Remove expired entries from the database. This is potentially expensive, so only run when it is acceptable to take time.
- _filenameEscape() : string
- _getAssociation() : Auth_OpenID_Association|null
- _isFilenameSafe() : bool
- _listdir() : array<string|int, mixed>
- _mkdtemp() : bool|string
- _mkstemp() : bool|string
- _mktemp() : array<string|int, mixed>
- Create a temporary file on the same filesystem as $this->association_dir.
- _removeIfPresent() : bool
- Attempt to remove a file, returning whether the file existed at the time of the call.
- _rmtree() : bool
- _safe64() : mixed|string
- _setup() : mixed
- Make sure that the directories in which we store our data exist.
- clean() : mixed
- cleanup() : array<string|int, mixed>
- Shortcut for cleanupNonces(), cleanupAssociations().
- cleanupAssociations() : int
- Remove expired associations from the store.
- cleanupNonces() : int
- Remove expired nonces from the store.
- destroy() : mixed
- getAssociation() : Auth_OpenID_Association|mixed|null
- Retrieve an association. If no handle is specified, return the association with the most recent issue time.
- getAssociationFilename() : string
- 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.
- removeAssociation() : bool
- Remove an association if it exists. Do nothing if it does not.
- reset() : mixed
- Removes all entries from the store; implementation is optional.
- storeAssociation() : bool
- Store an association in the association directory.
- supportsCleanup() : mixed
- Report whether this storage supports cleanup
- useNonce() : bool
- Return whether this nonce is present. As a side effect, mark it as no longer present.
Properties
$active
protected
mixed
$active
= \false
$association_dir
protected
mixed
$association_dir
= ''
$directory
protected
mixed
$directory
= ''
$max_nonce_age
protected
mixed
$max_nonce_age
= 0
$nonce_dir
protected
mixed
$nonce_dir
= ''
$temp_dir
protected
mixed
$temp_dir
= ''
Methods
__construct()
Initializes a new {@link Auth_OpenID_FileStore}. This initializes the nonce and association directories, which are subdirectories of the directory passed in.
public
__construct(string $directory) : mixed
Parameters
- $directory : string
-
This is the directory to put the store directories in.
Return values
mixed —_allAssocs()
Remove expired entries from the database. This is potentially expensive, so only run when it is acceptable to take time.
public
_allAssocs() : mixed
Tags
Return values
mixed —_filenameEscape()
public
_filenameEscape(string $str) : string
Parameters
- $str : string
Tags
Return values
string —_getAssociation()
public
_getAssociation(string $filename) : Auth_OpenID_Association|null
Parameters
- $filename : string
Tags
Return values
Auth_OpenID_Association|null —_isFilenameSafe()
public
_isFilenameSafe(string $char) : bool
Parameters
- $char : string
Tags
Return values
bool —_listdir()
public
_listdir(string $dir) : array<string|int, mixed>
Parameters
- $dir : string
Tags
Return values
array<string|int, mixed> —_mkdtemp()
public
static _mkdtemp(string $dir) : bool|string
Parameters
- $dir : string
Tags
Return values
bool|string —_mkstemp()
public
_mkstemp(string $dir) : bool|string
Parameters
- $dir : string
Tags
Return values
bool|string —_mktemp()
Create a temporary file on the same filesystem as $this->association_dir.
public
_mktemp() : array<string|int, mixed>
The temporary directory should not be cleaned if there are any processes using the store. If there is no active process using the store, it is safe to remove all of the files in the temporary directory.
Tags
Return values
array<string|int, mixed> —($fd, $filename)
_removeIfPresent()
Attempt to remove a file, returning whether the file existed at the time of the call.
public
_removeIfPresent(string $filename) : bool
Parameters
- $filename : string
Tags
Return values
bool —$result True if the file was present, false if not.
_rmtree()
public
_rmtree(string $dir) : bool
Parameters
- $dir : string
Tags
Return values
bool —_safe64()
public
_safe64(string $str) : mixed|string
Parameters
- $str : string
Tags
Return values
mixed|string —_setup()
Make sure that the directories in which we store our data exist.
public
_setup() : mixed
Tags
Return values
mixed —clean()
public
clean() : mixed
Return values
mixed —cleanup()
Shortcut for cleanupNonces(), cleanupAssociations().
public
cleanup() : array<string|int, mixed>
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.
Return values
array<string|int, mixed> —cleanupAssociations()
Remove expired associations from the store.
public
cleanupAssociations() : int
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.
Return values
int —the number of associations expired.
cleanupNonces()
Remove expired nonces from the store.
public
cleanupNonces() : int
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.
Return values
int —the number of nonces expired
destroy()
public
destroy() : mixed
Return values
mixed —getAssociation()
Retrieve an association. If no handle is specified, return the association with the most recent issue time.
public
getAssociation(string $server_url[, string|null $handle = null ]) : Auth_OpenID_Association|mixed|null
Parameters
- $server_url : string
- $handle : string|null = null
Return values
Auth_OpenID_Association|mixed|null —getAssociationFilename()
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.
public
getAssociationFilename(string $server_url, string $handle) : string
Parameters
- $server_url : string
- $handle : string
Return values
string —$filename
removeAssociation()
Remove an association if it exists. Do nothing if it does not.
public
removeAssociation(string $server_url, string $handle) : bool
Parameters
- $server_url : string
- $handle : string
Return values
bool —$success
reset()
Removes all entries from the store; implementation is optional.
public
reset() : mixed
Return values
mixed —storeAssociation()
Store an association in the association directory.
public
storeAssociation(string $server_url, Auth_OpenID_Association $association) : bool
Parameters
- $server_url : string
- $association : Auth_OpenID_Association
Return values
bool —supportsCleanup()
Report whether this storage supports cleanup
public
supportsCleanup() : mixed
Return values
mixed —useNonce()
Return whether this nonce is present. As a side effect, mark it as no longer present.
public
useNonce(string $server_url, int $timestamp, string $salt) : bool
Parameters
- $server_url : string
- $timestamp : int
- $salt : string
Return values
bool —$present