Skip to content

Commit 3fe331e

Browse files
committed
Only Checked Claims are returned
Fixes #67
1 parent 52a12b6 commit 3fe331e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Component/Checker/ClaimCheckerManager.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,14 @@ public function getCheckers(): array
7373
*/
7474
public function check(array $claims): array
7575
{
76+
$checkedClaims = [];
7677
foreach ($this->checkers as $claim => $checker) {
7778
if (array_key_exists($claim, $claims)) {
7879
$checker->checkClaim($claims[$claim]);
80+
$checkedClaims[$claim] = $claims[$claim];
7981
}
8082
}
8183

82-
return $claims;
84+
return $checkedClaims;
8385
}
8486
}

src/Component/Checker/Tests/ClaimCheckerManagerFactoryTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,13 @@ public function iCanCheckValidPayloadClaims()
6363
'exp' => time() + 3600,
6464
'iat' => time() - 1000,
6565
'nbf' => time() - 100,
66+
'foo' => 'bar',
6667
];
68+
$expected = $payload;
69+
unset($expected['foo']);
6770
$manager = $this->getClaimCheckerManagerFactory()->create(['exp', 'iat', 'nbf', 'aud']);
6871
$result = $manager->check($payload);
69-
self::assertEquals($payload, $result);
72+
self::assertEquals($expected, $result);
7073
}
7174

7275
/**

0 commit comments

Comments
 (0)