1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Facile\OpenIDClient\ConformanceTest\RpTest\IdToken; |
6
|
|
|
|
7
|
|
|
use Jose\Component\Core\JWK; |
8
|
|
|
use Jose\Component\Core\JWKSet; |
9
|
|
|
use Jose\Component\KeyManagement\JWKFactory; |
10
|
|
|
use PHPUnit\Framework\Assert; |
11
|
|
|
use Facile\OpenIDClient\ConformanceTest\RpTest\AbstractRpTest; |
12
|
|
|
use Facile\OpenIDClient\ConformanceTest\TestInfo; |
13
|
|
|
use Facile\OpenIDClient\Service\AuthorizationService; |
14
|
|
|
use function Facile\OpenIDClient\base64url_encode; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Request an signed ID Token. Verify the signature on the ID Token using the keys published by the Issuer. |
18
|
|
|
* |
19
|
|
|
* Accept the ID Token after doing ID Token validation. |
20
|
|
|
*/ |
21
|
|
|
class RpIdTokenSigEncA128KWTest extends AbstractRpTest |
22
|
|
|
{ |
23
|
|
|
|
24
|
|
|
public function getTestId(): string |
25
|
|
|
{ |
26
|
|
|
return 'rp-id_token-sig+enc-a128kw'; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function execute(TestInfo $testInfo): void |
30
|
|
|
{ |
31
|
|
|
$client = $this->registerClient($testInfo, [ |
32
|
|
|
'id_token_signed_response_alg' => 'RS256', |
33
|
|
|
'id_token_encrypted_response_alg' => 'A128KW', |
34
|
|
|
'id_token_encrypted_response_enc' => 'A256CBC-HS512', |
35
|
|
|
]); |
36
|
|
|
|
37
|
|
|
Assert::assertSame('RS256', $client->getMetadata()->get('id_token_signed_response_alg')); |
38
|
|
|
Assert::assertSame('A128KW', $client->getMetadata()->get('id_token_encrypted_response_alg')); |
39
|
|
|
Assert::assertSame('A256CBC-HS512', $client->getMetadata()->get('id_token_encrypted_response_enc')); |
40
|
|
|
|
41
|
|
|
// Get authorization redirect uri |
42
|
|
|
$authorizationService = new AuthorizationService(); |
|
|
|
|
43
|
|
|
$uri = $authorizationService->getAuthorizationUri($client, [ |
44
|
|
|
'response_type' => $testInfo->getResponseType(), |
45
|
|
|
'nonce' => base64url_encode(\random_bytes(32)), |
46
|
|
|
]); |
47
|
|
|
|
48
|
|
|
// Simulate a redirect and create the server request |
49
|
|
|
$serverRequest = $this->simulateAuthRedirect($uri); |
50
|
|
|
$params = $authorizationService->getCallbackParams($serverRequest, $client); |
51
|
|
|
|
52
|
|
|
$tokenSet = $authorizationService->callback($client, $params); |
53
|
|
|
|
54
|
|
|
Assert::assertNotNull($tokenSet->getIdToken()); |
55
|
|
|
Assert::arrayHasKey('email', $tokenSet->claims()); |
|
|
|
|
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
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.