1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Facile\OpenIDClient\ConformanceTest\RpTest\IdToken; |
6
|
|
|
|
7
|
|
|
use PHPUnit\Framework\Assert; |
8
|
|
|
use PHPUnit\Framework\AssertionFailedError; |
9
|
|
|
use Facile\OpenIDClient\ConformanceTest\RpTest\AbstractRpTest; |
10
|
|
|
use Facile\OpenIDClient\ConformanceTest\TestInfo; |
11
|
|
|
use Facile\OpenIDClient\Service\AuthorizationService; |
12
|
|
|
use function Facile\OpenIDClient\base64url_encode; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Request an ID token and verify its signature using the keys provided by the Issuer. |
16
|
|
|
* |
17
|
|
|
* Identify the invalid signature and reject the ID Token after doing ID Token validation. |
18
|
|
|
*/ |
19
|
|
|
class RpIdTokenBadSigRS256Test extends AbstractRpTest |
20
|
|
|
{ |
21
|
|
|
|
22
|
|
|
public function getTestId(): string |
23
|
|
|
{ |
24
|
|
|
return 'rp-id_token-bad-sig-rs256'; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function execute(TestInfo $testInfo): void |
28
|
|
|
{ |
29
|
|
|
$client = $this->registerClient($testInfo); |
30
|
|
|
|
31
|
|
|
// Get authorization redirect uri |
32
|
|
|
$authorizationService = new AuthorizationService(); |
|
|
|
|
33
|
|
|
$uri = $authorizationService->getAuthorizationUri($client, [ |
34
|
|
|
'response_type' => $testInfo->getResponseType(), |
35
|
|
|
'nonce' => base64url_encode(\random_bytes(32)), |
36
|
|
|
]); |
37
|
|
|
|
38
|
|
|
// Simulate a redirect and create the server request |
39
|
|
|
$serverRequest = $this->simulateAuthRedirect($uri); |
40
|
|
|
|
41
|
|
|
$params = $authorizationService->getCallbackParams($serverRequest, $client); |
42
|
|
|
|
43
|
|
|
try { |
44
|
|
|
$authorizationService->callback($client, $params); |
45
|
|
|
throw new AssertionFailedError('No assertion'); |
46
|
|
|
} catch (\Throwable $e) { |
47
|
|
|
Assert::assertSame('Invalid token provided', $e->getMessage()); |
48
|
|
|
Assert::assertRegExp('/Invalid signature/', $e->getPrevious()->getMessage()); |
|
|
|
|
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
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.