Skip to content

Commit dce724d

Browse files
authored
Add check for 'ath' claim
Updated JWT DPoP validation to check for 'ath' claim and throw an exception if missing.
1 parent ebdff6f commit dce724d

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

src/Utils/DPop.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,17 +166,18 @@ public function makeJwkThumbprint($jwk) {
166166
public function validateJwtDpop($jwt, $dpop, $request) {
167167
$this->validateDpop($dpop, $request);
168168
$jwtConfig = Configuration::forUnsecuredSigner();
169-
$jwtConfig->parser()->parse($dpop);
170-
171-
/**
172-
* @FIXME: ATH claim is not yet supported/required by the Solid OIDC specification.
173-
* Once the Solid spec catches up to the DPOP spec, not having an ATH is incorrect.
174-
* At that point, instead of returning "true", throw an exception:
175-
*
176-
* @see https://github.com/pdsinterop/php-solid-auth/issues/34
177-
*/
178-
// throw new InvalidTokenException('DPoP "ath" claim is missing');
179-
return true;
169+
$dpopJWT = $jwtConfig->parser()->parse($dpop);
170+
171+
$ath = $dpopJWT->claims()->get('ath');
172+
173+
if ($ath === null) {
174+
throw new InvalidTokenException('DPoP "ath" claim is missing');
175+
}
176+
177+
$hash = hash('sha256', $jwt);
178+
$encoded = Base64Url::encode($hash);
179+
180+
return ($ath === $encoded);
180181
}
181182

182183
/**

0 commit comments

Comments
 (0)