Skip to content

Key id must match in all circumstances #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/KeyRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/ProviderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down