1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Facile\OpenIDClient\ConformanceTest\RpTest\IdToken; |
6
|
|
|
|
7
|
|
|
use PHPUnit\Framework\Assert; |
8
|
|
|
use Facile\OpenIDClient\ConformanceTest\RpTest\AbstractRpTest; |
9
|
|
|
use Facile\OpenIDClient\ConformanceTest\TestInfo; |
10
|
|
|
use Facile\OpenIDClient\Service\AuthorizationService; |
11
|
|
|
use function Facile\OpenIDClient\base64url_encode; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Request an ID token and verify its signature using the keys provided by the Issuer. |
15
|
|
|
* |
16
|
|
|
* Identify that the 'kid' value is missing from the JOSE header and that the Issuer publishes multiple keys in its |
17
|
|
|
* JWK Set document (referenced by 'jwks_uri'). The RP can do one of two things; reject the ID Token since it can not |
18
|
|
|
* by using the kid determined which key to use to verify the signature. Or it can just test all possible keys and hit |
19
|
|
|
* upon one that works, which it will in this case. |
20
|
|
|
*/ |
21
|
|
|
class RpIdTokenKidAbsentMultipleJwksTest extends AbstractRpTest |
22
|
|
|
{ |
23
|
|
|
|
24
|
|
|
public function getTestId(): string |
25
|
|
|
{ |
26
|
|
|
return 'rp-id_token-kid-absent-multiple-jwks'; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function execute(TestInfo $testInfo): void |
30
|
|
|
{ |
31
|
|
|
$client = $this->registerClient($testInfo); |
32
|
|
|
|
33
|
|
|
// Get authorization redirect uri |
34
|
|
|
$authorizationService = new AuthorizationService(); |
|
|
|
|
35
|
|
|
$uri = $authorizationService->getAuthorizationUri($client, [ |
36
|
|
|
'response_type' => $testInfo->getResponseType(), |
37
|
|
|
'nonce' => base64url_encode(\random_bytes(32)), |
38
|
|
|
]); |
39
|
|
|
|
40
|
|
|
// Simulate a redirect and create the server request |
41
|
|
|
$serverRequest = $this->simulateAuthRedirect($uri); |
42
|
|
|
$params = $authorizationService->getCallbackParams($serverRequest, $client); |
43
|
|
|
|
44
|
|
|
$tokenSet = $authorizationService->callback($client, $params); |
45
|
|
|
|
46
|
|
|
Assert::assertNotNull($tokenSet->getIdToken()); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.