| 1 | <?php |
||
| 17 | class OneTimePasswordValidator implements ValidatorInterface |
||
| 18 | { |
||
| 19 | use OathTrait; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var string |
||
| 23 | */ |
||
| 24 | protected $seed; |
||
| 25 | /** |
||
| 26 | * @var int |
||
| 27 | */ |
||
| 28 | protected $cycles; |
||
| 29 | /** |
||
| 30 | * @var int |
||
| 31 | */ |
||
| 32 | protected $startTime; |
||
| 33 | /** |
||
| 34 | * @var int |
||
| 35 | */ |
||
| 36 | protected $time; |
||
| 37 | /** |
||
| 38 | * @var int|null |
||
| 39 | */ |
||
| 40 | protected $previousTime; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * OneTimePasswordValidator constructor. |
||
| 44 | * |
||
| 45 | * @param string $seed |
||
| 46 | * @param int $cycles |
||
| 47 | * @param int $tokenLength |
||
| 48 | * @param int $startTime |
||
| 49 | * @param int $time |
||
| 50 | * @param int|null $previousTime |
||
| 51 | */ |
||
| 52 | public function __construct( |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Validates OTP. If `$previousTime` has been added, it will return the `$startTime`, otherwise it will return a |
||
| 70 | * bool value. This is done to prevent an attacker to use the same key again. |
||
| 71 | * |
||
| 72 | * @param mixed $value |
||
| 73 | * |
||
| 74 | * @return bool|int |
||
| 75 | */ |
||
| 76 | public function validate($value) |
||
| 89 | } |
||
| 90 |