You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The verifier MUST NOT accept
the second attempt of the OTP after the successful validation has
been issued for the first OTP, which ensures one-time only use of an
OTP.
It would be nice to have the Totp->verify() function to optionally accept an argument of the previous time the verify function was used. Though this timestamp of course has to be stored in the app itself, it would be nice to have the functionality to check the timestamp inside the package.
This could also be done by mentioning explicitly in the documentation that it is best practice to not accept reuse of OTPs.
If this you see the benefit of adding this I will happily open a PR.
Example
Could be achieved by e.g.:
publicfunction verify(string$otp, null|int$timestamp = null, null|int$leeway = null, null|int$previousTimestamp = null): bool
{
$timestamp ??= $this->clock->now()
->getTimestamp();
$timestamp >= 0 || thrownewInvalidArgumentException('Timestamp must be at least 0.');
if ($previousTimestamp !== null) {
$previousTimestamp >= 0 || thrownewInvalidArgumentException('Previous timestamp must be at least 0.');
if ($this->at($timestamp) === $this->at($previousTimestamp)) {
returnfalse;
}
}
...
OR
publicfunction verify(string$otp, null|int$timestamp = null, null|int$leeway = null, null|int$previousTimestamp = null): bool
{
$timestamp ??= $this->clock->now()
->getTimestamp();
$timestamp >= 0 || thrownewInvalidArgumentException('Timestamp must be at least 0.');
if ($previousTimestamp !== null) {
$previousTimestamp >= 0 || thrownewInvalidArgumentException('Previous timestamp must be at least 0.');
if ($timestamp < $this->timecode($previousTimestamp) + $this->getPeriod()) {
returnfalse;
}
}
...
The text was updated successfully, but these errors were encountered:
There is no reason to introduce a new interface to keep track on past OTPs in this library.
This can easily be achieved on the application side with a caching system, a database or files.
Same goes for the bruteforce prevention means.
Description
As the RFC6238 states the following:
It would be nice to have the Totp->verify() function to optionally accept an argument of the previous time the verify function was used. Though this timestamp of course has to be stored in the app itself, it would be nice to have the functionality to check the timestamp inside the package.
This could also be done by mentioning explicitly in the documentation that it is best practice to not accept reuse of OTPs.
If this you see the benefit of adding this I will happily open a PR.
Example
Could be achieved by e.g.:
OR
The text was updated successfully, but these errors were encountered: