Skip to content

Commit 673fd71

Browse files
committed
Hash nonce when using as file name
1 parent 5f125f3 commit 673fd71

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cookbook/security/custom_authentication_provider.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,17 @@ the ``PasswordDigest`` header value matches with the user's password.
256256
257257
// Validate that the nonce is *not* used in the last 5 minutes
258258
// if it has, this could be a replay attack
259-
if (file_exists($this->cacheDir.'/'.$nonce) && file_get_contents($this->cacheDir.'/'.$nonce) + 300 > time()) {
259+
if (
260+
file_exists($this->cacheDir.'/'.md5($nonce))
261+
&& file_get_contents($this->cacheDir.'/'.md5($nonce)) + 300 > time()
262+
) {
260263
throw new NonceExpiredException('Previously used nonce detected');
261264
}
262265
// If cache directory does not exist we create it
263266
if (!is_dir($this->cacheDir)) {
264267
mkdir($this->cacheDir, 0777, true);
265268
}
266-
file_put_contents($this->cacheDir.'/'.$nonce, time());
269+
file_put_contents($this->cacheDir.'/'.md5($nonce), time());
267270
268271
// Validate Secret
269272
$expected = base64_encode(sha1(base64_decode($nonce).$created.$secret, true));

0 commit comments

Comments
 (0)