Conditions | 2 |
Paths | 2 |
Total Lines | 22 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 2.0014 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
24 | 4 | public function run() |
|
25 | { |
||
26 | 4 | if (!extension_loaded('openssl')) { |
|
27 | throw new InvalidConfigException('JWKS functionality requires the openssl extension to be loaded in PHP.'); |
||
28 | } |
||
29 | |||
30 | 4 | $module = $this->controller->module; |
|
31 | |||
32 | 4 | $publicKey = $module->getPublicKey(); |
|
33 | |||
34 | 4 | $keyInfo = openssl_pkey_get_details(openssl_pkey_get_public($publicKey->getKeyContents())); |
|
35 | |||
36 | 4 | $keys = [new JWK([ |
|
37 | // ToDo 'kid' => '', // https://datatracker.ietf.org/doc/html/rfc7517#section-4.5. |
||
38 | 4 | 'kty' => 'RSA', |
|
39 | 4 | 'alg' => 'RS256', // https://datatracker.ietf.org/doc/html/rfc7518#section-6.3. |
|
40 | 4 | 'use' => 'sig', |
|
41 | 4 | 'n' => rtrim(StringHelper::base64UrlEncode($keyInfo['rsa']['n']), '='), |
|
42 | 4 | 'e' => rtrim(StringHelper::base64UrlEncode($keyInfo['rsa']['e']), '='), |
|
43 | 4 | ])]; |
|
44 | |||
45 | 4 | return new JWKSet($keys); |
|
46 | } |
||
48 |