diff --git a/src/KeyRepository.php b/src/KeyRepository.php index c86590b..7b7568e 100644 --- a/src/KeyRepository.php +++ b/src/KeyRepository.php @@ -8,25 +8,31 @@ class KeyRepository { - public function getPrivateKey(): CryptKey + public function getPrivateKey(string $kid = "1"): CryptKey { $privateKey = config('passport.private_key') ?? 'file://' . Passport::keyPath('oauth-private.key'); - return new CryptKey($privateKey); + $cryptKey = new CryptKey($privateKey); + $cryptKey->setKid($kid); + return $cryptKey; } - public function getPublicKey(): CryptKey + public function getPublicKey(string $kid = "1"): CryptKey { $publicKey = config('passport.public_key') ?? 'file://' . Passport::keyPath('oauth-public.key'); - return new CryptKey($publicKey); + $cryptKey = new CryptKey($publicKey); + $cryptKey->setKid($kid); + return $cryptKey; } - public function getPublicKeyForClient(Client $client, $kid = null): CryptKey + public function getPublicKeyForClient(Client $client, string $kid = "1"): CryptKey { $publicKey = config('passport.public_key') ?? file_get_contents('file://' . Passport::keyPath('oauth-public.key')); - return new CryptKey($publicKey); + $cryptKey = new CryptKey($publicKey); + $cryptKey->setKid($kid); + return $cryptKey; } public function getAllPublicKeys() diff --git a/src/ProviderController.php b/src/ProviderController.php index f867074..fbea3c2 100644 --- a/src/ProviderController.php +++ b/src/ProviderController.php @@ -66,7 +66,7 @@ public function jwks(ProviderRepository $providerRepository) 'alg' => 'RS256', 'kty' => 'RSA', 'use' => 'sig', - 'kid' => $crypt->kid ?? 1 + 'kid' => $crypt->kid, ]; if (!empty($crypt->x509)) {