Skip to content

Commit bb63483

Browse files
committed
add key ID to the ID token, used for non-dpop applications
1 parent 60464a6 commit bb63483

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/TokenGenerator.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Pdsinterop\Solid\Auth\Exception\InvalidTokenException;
66
use Pdsinterop\Solid\Auth\Utils\DPop;
7+
use Pdsinterop\Solid\Auth\Utils\Jwks;
78
use Pdsinterop\Solid\Auth\Enum\OpenId\OpenIdConnectMetadata as OidcMeta;
89
use Laminas\Diactoros\Response\JsonResponse;
910
use League\OAuth2\Server\CryptTrait;
@@ -88,6 +89,10 @@ public function generateIdToken($accessToken, $clientId, $subject, $nonce, $priv
8889
$token = $token->withClaim("cnf", [
8990
"jkt" => $jkt,
9091
]);
92+
} else {
93+
// legacy mode
94+
$jwks = $this->getJwks();
95+
$token = $token->withHeader('kid', $jwks['keys'][0]['kid']);
9196
}
9297

9398
return $token->getToken($jwtConfig->signer(), $jwtConfig->signingKey())->toString();
@@ -201,4 +206,10 @@ private function makeJwkThumbprint($dpop): string
201206

202207
return $this->dpopUtil->makeJwkThumbprint($jwk);
203208
}
209+
210+
private function getJwks() {
211+
$key = $this->config->getKeys()->getPublicKey();
212+
$jwks = new Jwks($key);
213+
return json_decode($jwks->__toString(), true);
214+
}
204215
}

0 commit comments

Comments
 (0)