Skip to content

Commit 8afcdc6

Browse files
committed
Change DPOP to not make KID required.
1 parent e07c22d commit 8afcdc6

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/Utils/DPop.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,20 @@ public function getWebId($request) {
8787
* @throws RequiredConstraintsViolated
8888
*/
8989
public function getDpopKey($dpop, $request) {
90+
$kid = '';
91+
9092
$this->validateDpop($dpop, $request);
9193

9294
// 1. the string value is a well-formed JWT,
9395
$jwtConfig = Configuration::forUnsecuredSigner();
9496
$dpop = $jwtConfig->parser()->parse($dpop);
9597
$jwk = $dpop->headers()->get("jwk");
9698

97-
if (isset($jwk['kid']) === false) {
98-
throw new InvalidTokenException('Key ID is missing from JWK header');
99+
if (isset($jwk['kid'])) {
100+
$kid = $jwk['kid'];
99101
}
100102

101-
return $jwk['kid'];
103+
return $kid;
102104
}
103105

104106
private function validateJwtDpop($jwt, $dpopKey) {

tests/unit/Utils/DPOPTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ final public function testGetWebIdWithoutDpop(): void
311311
}
312312

313313
/**
314-
* @testdox Dpop SHOULD complain WHEN asked to get WebId from Request with valid DPOP without JWT Key Id
314+
* @testdox Dpop SHOULD return given "sub" WHEN asked to get WebId from Request with valid DPOP without JWT Key Id
315315
*
316316
* @covers ::getWebId
317317
*
@@ -340,10 +340,10 @@ final public function testGetWebIdWithDpopWithoutKeyId(): void
340340
'HTTP_DPOP' => $token['token'],
341341
),array(), $this->url);
342342

343-
$this->expectException(InvalidTokenException::class);
344-
$this->expectExceptionMessage('Key ID is missing from JWK header');
343+
$actual = $dpop->getWebId($request);
344+
$expected = 'mock sub';
345345

346-
$dpop->getWebId($request);
346+
$this->assertEquals($expected, $actual);
347347
}
348348

349349
/**

0 commit comments

Comments
 (0)