Skip to content

Commit f342bd8

Browse files
fix backward compatibility
1 parent f51da5f commit f342bd8

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"ext-openssl": "*",
99
"league/event": "^3.0",
1010
"league/uri": "^7.0",
11-
"lcobucci/jwt": "^5.5",
11+
"lcobucci/jwt": "^5.0",
1212
"psr/http-message": "^2.0",
1313
"defuse/php-encryption": "^2.4",
1414
"ext-json": "*",

src/AuthorizationValidators/BearerTokenValidator.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ public function setPublicKey(CryptKeyInterface $key): void
6161
*/
6262
private function initJwtConfiguration(): void
6363
{
64+
$this->jwtConfiguration = Configuration::forSymmetricSigner(
65+
new Sha256(),
66+
InMemory::plainText('empty', 'empty')
67+
);
68+
6469
$clock = new SystemClock(new DateTimeZone(date_default_timezone_get()));
6570

6671
$publicKeyContents = $this->publicKey->getKeyContents();
@@ -69,16 +74,20 @@ private function initJwtConfiguration(): void
6974
throw new RuntimeException('Public key is empty');
7075
}
7176

72-
$this->jwtConfiguration = Configuration::forSymmetricSigner(
73-
new Sha256(),
74-
InMemory::plainText('empty', 'empty')
75-
)->withValidationConstraints(
77+
$validationConstraints = [
7678
new LooseValidAt($clock, $this->jwtValidAtDateLeeway),
7779
new SignedWith(
7880
new Sha256(),
7981
InMemory::plainText($publicKeyContents, $this->publicKey->getPassPhrase() ?? '')
8082
)
81-
);
83+
];
84+
85+
// TODO: next major release: remove this check
86+
if (method_exists($this->jwtConfiguration, 'withValidationConstraints') === true) {
87+
$this->jwtConfiguration = $this->jwtConfiguration->withValidationConstraints(...$validationConstraints);
88+
} else {
89+
$this->jwtConfiguration->setValidationConstraints(...$validationConstraints);
90+
}
8291
}
8392

8493
/**

src/Entities/ClientEntityInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function isConfidential(): bool;
4242
/*
4343
* Returns true if the client supports the given grant type.
4444
*
45-
* To be added in a future major release.
45+
* TODO: To be added in a future major release.
4646
*/
4747
// public function supportsGrantType(string $grantType): bool;
4848
}

0 commit comments

Comments
 (0)