Skip to content

Commit

Permalink
feat: remove lcobucci/jwt deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
kochen committed Mar 10, 2024
1 parent 35e6fb0 commit a0f60be
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 77 deletions.
3 changes: 0 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
<include>
<directory>src</directory>
</include>
<exclude>
<file>src/Security/Jwt/Decoder/AssociativeDecoder.php</file>
</exclude>
</coverage>
<php>
<env name="TEST_KEYS_ROOT_DIR" value="file://tests/Resource/Key/RSA"/>
Expand Down
10 changes: 0 additions & 10 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,6 @@
<file name="src/Service/Server/LtiServiceServer.php"/>
</errorLevel>
</TypeDoesNotContainType>
<UndefinedClass>
<errorLevel type="suppress">
<file name="src/Security/Jwt/Decoder/AssociativeDecoder.php"/>
</errorLevel>
</UndefinedClass>
<UndefinedConstant>
<errorLevel type="suppress">
<file name="src/Security/Jwt/Decoder/AssociativeDecoder.php"/>
</errorLevel>
</UndefinedConstant>
<RedundantCondition>
<errorLevel type="suppress">
<file name="src/Message/LtiMessage.php"/>
Expand Down
1 change: 0 additions & 1 deletion src/Security/Jwt/Builder/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public function build(array $headers, array $claims, KeyInterface $key): TokenIn
MessagePayloadInterface::CLAIM_EXP => $now->addSeconds($this->messageTtl)->toDateTimeImmutable(),
]
);

foreach ($claims as $claimName => $claimValue) {
switch ($claimName) {
case MessagePayloadInterface::CLAIM_JTI:
Expand Down
16 changes: 6 additions & 10 deletions src/Security/Jwt/Configuration/ConfigurationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@

use Lcobucci\Clock\SystemClock;
use Lcobucci\JWT\Configuration;
use Lcobucci\JWT\Encoding\JoseEncoder;
use Lcobucci\JWT\Signer\Key;
use Lcobucci\JWT\Signer\Key\InMemory;
use Lcobucci\JWT\Validation\Constraint\LooseValidAt;
use Lcobucci\JWT\Validation\Constraint\SignedWith;
use Lcobucci\JWT\Validation\Constraint\ValidAt;
use OAT\Library\Lti1p3Core\Security\Jwt\Converter\KeyConverter;
use OAT\Library\Lti1p3Core\Security\Jwt\Decoder\AssociativeDecoder;
use OAT\Library\Lti1p3Core\Security\Jwt\Signer\SignerFactory;
use OAT\Library\Lti1p3Core\Security\Key\KeyInterface;

Expand All @@ -51,18 +51,16 @@ public function create(?KeyInterface $signingKey = null, ?KeyInterface $verifica
{
$algorithm = $this->findAlgorithm($signingKey, $verificationKey);

$decoder = class_exists('Lcobucci\JWT\Parsing\Decoder') ? new AssociativeDecoder() : null;

$configuration = Configuration::forAsymmetricSigner(
$this->factory->create($algorithm),
$this->convertKey($signingKey),
$this->convertKey($verificationKey),
null,
$decoder
new JoseEncoder(),
new JoseEncoder(),
);

$configuration->setValidationConstraints(
new ValidAt(SystemClock::fromUTC()),
new LooseValidAt(SystemClock::fromUTC()),
new SignedWith($configuration->signer(), $configuration->verificationKey())
);

Expand All @@ -85,9 +83,7 @@ private function findAlgorithm(?KeyInterface $signingKey = null, ?KeyInterface $
private function convertKey(?KeyInterface $key = null): Key
{
if (null === $key) {
return method_exists(InMemory::class, 'empty')
? InMemory::empty()
: InMemory::plainText('');
return InMemory::plainText('empty', 'empty');
}

return $this->converter->convert($key);
Expand Down
53 changes: 0 additions & 53 deletions src/Security/Jwt/Decoder/AssociativeDecoder.php

This file was deleted.

0 comments on commit a0f60be

Please sign in to comment.