diff options
author | tailor <cygnus@janrain.com> | 2007-09-24 18:01:32 +0000 |
---|---|---|
committer | tailor <cygnus@janrain.com> | 2007-09-24 18:01:32 +0000 |
commit | 0f270daead5c4821861718c734e55e54ed7ca4d7 (patch) | |
tree | 239b4178faca7f2f9552066985efb6d199120807 /Auth/OpenID/FileStore.php | |
parent | 2616c4c0e21689c727ff3472b502d35a425ef9a5 (diff) | |
download | php-openid-0f270daead5c4821861718c734e55e54ed7ca4d7.zip php-openid-0f270daead5c4821861718c734e55e54ed7ca4d7.tar.gz php-openid-0f270daead5c4821861718c734e55e54ed7ca4d7.tar.bz2 |
[project @ Added cleanupNonces to store interface and file store]
Diffstat (limited to 'Auth/OpenID/FileStore.php')
-rw-r--r-- | Auth/OpenID/FileStore.php | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Auth/OpenID/FileStore.php b/Auth/OpenID/FileStore.php index 34266ca..50dca78 100644 --- a/Auth/OpenID/FileStore.php +++ b/Auth/OpenID/FileStore.php @@ -116,6 +116,29 @@ class Auth_OpenID_FileStore extends Auth_OpenID_OpenIDStore { } } + function cleanupNonces() + { + global $Auth_OpenID_SKEW; + + $nonces = Auth_OpenID_FileStore::_listdir($this->nonce_dir); + $now = time(); + + $removed = 0; + // Check all nonces for expiry + foreach ($nonces as $nonce_fname) { + $parts = explode('-', $nonce_fname, 2); + $timestamp = $parts[0]; + $timestamp = intval($timestamp, 16); + if (abs($timestamp - $now) > $Auth_OpenID_SKEW) { + $filename = $this->nonce_dir . DIRECTORY_SEPARATOR . + $nonce_fname; + Auth_OpenID_FileStore::_removeIfPresent($filename); + $removed += 1; + } + } + return $removed; + } + /** * Create a unique filename for a given server url and * handle. This implementation does not assume anything about the |