Skip to content

Commit 93a4a42

Browse files
committed
add iat en exp validation for dpop token
1 parent c9e7f61 commit 93a4a42

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/Utils/DPop.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Lcobucci\JWT\Parser;
66
use Lcobucci\JWT\Signer\Key;
7+
use Lcobucci\JWT\ValidationData;
78
use CoderCat\JWKToPEM\JWKConverter;
89

910
class DPop {
@@ -151,9 +152,11 @@ private function validateDpop($dpop, $request) {
151152

152153
//error_log("8");
153154
// 8. the token was issued within an acceptable timeframe (see Section 9.1), and
154-
// $iat = $dpop->getClaim("iat"); // FIXME: Is it correct that this was already verified by the parser?
155-
// $exp = $dpop->getClaim("exp"); // FIXME: Is it correct that this was already verified by the parser?
156-
155+
$validationData = new ValidationData(); // It will use the current time to validate (iat, nbf and exp)
156+
if (!$dpop->validate($validationData)) {
157+
throw new \Exception("token timing is invalid");
158+
}
159+
157160
// 9. that, within a reasonable consideration of accuracy and resource utilization, a JWT with the same "jti" value has not been received previously (see Section 9.1).
158161
// FIXME: Check if we know the jti;
159162
//error_log("9");

0 commit comments

Comments
 (0)