Skip to content

Commit 6833c30

Browse files
committed
[symfony#3134] Trying to clarify the purpose of the nonce logic
1 parent c10d37f commit 6833c30

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cookbook/security/custom_authentication_provider.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,12 @@ the ``PasswordDigest`` header value matches with the user's password.
227227
throw new AuthenticationException('The WSSE authentication failed.');
228228
}
229229
230+
/**
231+
* This function is specific to Wsse authentication and is only used to help this example
232+
*
233+
* For more information specific to the logic here, see
234+
* https://github.com/symfony/symfony-docs/pull/3134#issuecomment-27699129
235+
*/
230236
protected function validateDigest($digest, $nonce, $created, $secret)
231237
{
232238
// Check created time is not in the future
@@ -239,7 +245,8 @@ the ``PasswordDigest`` header value matches with the user's password.
239245
return false;
240246
}
241247
242-
// Validate nonce is unique within 5 minutes
248+
// Validate that the nonce is *not* used in the last 5 minutes
249+
// if it has, this could be a replay attack
243250
if (file_exists($this->cacheDir.'/'.$nonce) && file_get_contents($this->cacheDir.'/'.$nonce) + 300 > time()) {
244251
throw new NonceExpiredException('Previously used nonce detected');
245252
}

0 commit comments

Comments
 (0)