Skip to content

Commit 85376d0

Browse files
committed
Simplify Web-Token integration and adjust CI for compatibility with updated packages
1 parent 02ea57f commit 85376d0

File tree

7 files changed

+20
-9
lines changed

7 files changed

+20
-9
lines changed

.github/workflows/web-token-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151

5252
- name: "Require web-token/*"
5353
run: |
54-
composer require --dev --no-update web-token/jwt-bundle:"^3.3.3"
54+
composer require --dev --no-update web-token/jwt-bundle:"^3.3.3|^4.0"
5555
composer require --dev --no-update spomky-labs/aes-key-wrap:"^7.0"
5656
5757
- name: "Install dependencies"

Command/EnableEncryptionConfigCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Jose\Component\Core\AlgorithmManagerFactory;
99
use Jose\Component\Core\JWK;
1010
use Jose\Component\Core\JWKSet;
11+
use Jose\Component\Core\Util\Base64UrlSafe;
1112
use Jose\Component\Encryption\Algorithm\ContentEncryptionAlgorithm;
1213
use Jose\Component\Encryption\Algorithm\KeyEncryptionAlgorithm;
1314
use Jose\Component\Encryption\JWEBuilder;
@@ -16,7 +17,6 @@
1617
use Jose\Component\Signature\JWSBuilder;
1718
use Jose\Component\Signature\JWSLoader;
1819
use Lexik\Bundle\JWTAuthenticationBundle\Services\KeyLoader\KeyLoaderInterface;
19-
use ParagonIE\ConstantTime\Base64UrlSafe;
2020
use Symfony\Bundle\FrameworkBundle\Command\AbstractConfigCommand;
2121
use Symfony\Component\Config\Definition\Processor;
2222
use Symfony\Component\Console\Attribute\AsCommand;

Command/MigrateConfigCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
use Jose\Component\Checker\ClaimCheckerManager;
77
use Jose\Component\Core\JWK;
88
use Jose\Component\Core\JWKSet;
9+
use Jose\Component\Core\Util\Base64UrlSafe;
910
use Jose\Component\KeyManagement\JWKFactory;
1011
use Jose\Component\Signature\JWSBuilder;
1112
use Jose\Component\Signature\JWSLoader;
1213
use Lexik\Bundle\JWTAuthenticationBundle\Services\KeyLoader\KeyLoaderInterface;
13-
use ParagonIE\ConstantTime\Base64UrlSafe;
1414
use Symfony\Bundle\FrameworkBundle\Command\AbstractConfigCommand;
1515
use Symfony\Component\Config\Definition\Processor;
1616
use Symfony\Component\Console\Attribute\AsCommand;

DependencyInjection/LexikJWTAuthenticationExtension.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,14 @@ private function processWithWebTokenConfig(array $config, ContainerBuilder $cont
241241
->replaceArgument(11, $config['access_token_verification']['encryption']['allowed_content_encryption_algorithms'])
242242
->replaceArgument(12, $config['access_token_verification']['encryption']['keyset'])
243243
;
244+
} else {
245+
$accessTokenLoaderDefinition
246+
->replaceArgument(8, null)
247+
->replaceArgument(9, null)
248+
->replaceArgument(10, null)
249+
->replaceArgument(11, null)
250+
->replaceArgument(12, null)
251+
;
244252
}
245253
}
246254
}

Resources/config/web_token_verification.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
66

77
<services>
8+
<service id="lexik_jwt_authentication.web_token.clock" class="Lcobucci\Clock\SystemClock" public="false">
9+
<factory class="Lcobucci\Clock\SystemClock" method="fromUTC" />
10+
</service>
811
<service id="lexik_jwt_authentication.access_token_loader" class="Lexik\Bundle\JWTAuthenticationBundle\Services\WebToken\AccessTokenLoader" public="false">
912
<argument type="service" id="Jose\Bundle\JoseFramework\Services\JWSLoaderFactory" />
1013
<argument type="service" id="Jose\Bundle\JoseFramework\Services\JWELoaderFactory" on-invalid="null" />
@@ -21,18 +24,21 @@
2124
<argument>null</argument> <!-- Encryption keyset -->
2225
</service>
2326
<service id="lexik_jwt_authentication.web_token.iat_validator" class="Jose\Component\Checker\IssuedAtChecker" public="false">
27+
<argument type="service">lexik_jwt_authentication.web_token.clock</argument>
2428
<argument>%lexik_jwt_authentication.clock_skew%</argument>
2529
<argument>true</argument>
2630
<tag name="jose.checker.claim" alias="iat_with_clock_skew" />
2731
<tag name="jose.checker.header" alias="iat_with_clock_skew" />
2832
</service>
2933
<service id="lexik_jwt_authentication.web_token.exp_validator" class="Jose\Component\Checker\ExpirationTimeChecker" public="false">
34+
<argument type="service">lexik_jwt_authentication.web_token.clock</argument>
3035
<argument>%lexik_jwt_authentication.clock_skew%</argument>
3136
<argument>true</argument>
3237
<tag name="jose.checker.claim" alias="exp_with_clock_skew" />
3338
<tag name="jose.checker.header" alias="exp_with_clock_skew" />
3439
</service>
3540
<service id="lexik_jwt_authentication.web_token.nbf_validator" class="Jose\Component\Checker\NotBeforeChecker" public="false">
41+
<argument type="service">lexik_jwt_authentication.web_token.clock</argument>
3642
<argument>%lexik_jwt_authentication.clock_skew%</argument>
3743
<argument>true</argument>
3844
<tag name="jose.checker.claim" alias="nbf_with_clock_skew" />

Services/WebToken/AccessTokenLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __construct(
4747
) {
4848
$this->jwsLoader = $jwsLoaderFactory->create(['jws_compact'], $signatureAlgorithms, $jwsHeaderChecker);
4949
if ($jweLoaderFactory !== null && !empty($keyEncryptionAlgorithms) && !empty($contentEncryptionAlgorithms) && !empty($jweHeaderChecker)) {
50-
$this->jweLoader = $jweLoaderFactory->create(['jwe_compact'], array_merge($keyEncryptionAlgorithms, $contentEncryptionAlgorithms), null, null, $jweHeaderChecker);
50+
$this->jweLoader = $jweLoaderFactory->create(['jwe_compact'], array_merge($keyEncryptionAlgorithms, $contentEncryptionAlgorithms), $jweHeaderChecker);
5151
$this->continueOnDecryptionFailure = $continueOnDecryptionFailure;
5252
}
5353
$this->signatureKeyset = JWKSet::createFromJson($signatureKeyset);

Tests/Functional/WebTokenTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
use Jose\Component\Core\AlgorithmManager;
66
use Jose\Component\Core\JWK;
7+
use Jose\Component\Core\Util\Base64UrlSafe;
78
use Jose\Component\Encryption\Algorithm\ContentEncryption\A128GCM;
89
use Jose\Component\Encryption\Algorithm\ContentEncryption\A256GCM;
910
use Jose\Component\Encryption\Algorithm\KeyEncryption\A128GCMKW;
1011
use Jose\Component\Encryption\Algorithm\KeyEncryption\A256GCMKW;
11-
use Jose\Component\Encryption\Compression\CompressionMethodManager;
1212
use Jose\Component\Encryption\JWEBuilder;
1313
use Jose\Component\Encryption\Serializer\CompactSerializer as JweCompactSerializer;
1414
use Jose\Component\Signature\Algorithm\HS256;
@@ -20,7 +20,6 @@
2020
use Lexik\Bundle\JWTAuthenticationBundle\Event\JWTInvalidEvent;
2121
use Lexik\Bundle\JWTAuthenticationBundle\Events;
2222
use Lexik\Bundle\JWTAuthenticationBundle\Response\JWTAuthenticationSuccessResponse;
23-
use ParagonIE\ConstantTime\Base64UrlSafe;
2423
use Symfony\Component\HttpFoundation\Cookie;
2524
use Symfony\Component\HttpFoundation\Request;
2625
use Symfony\Component\HttpFoundation\Response;
@@ -337,9 +336,7 @@ private function buildJWS(array $claims, array $header, JWK $signatureKey): stri
337336
private function buildJWE(string $payload, array $header, JWK $encryptionKey): string
338337
{
339338
$builder = new JWEBuilder(
340-
new AlgorithmManager([new A256GCMKW(), new A128GCMKW()]),
341-
new AlgorithmManager([new A256GCM(), new A128GCM()]),
342-
new CompressionMethodManager([])
339+
new AlgorithmManager([new A256GCMKW(), new A128GCMKW(), new A256GCM(), new A128GCM()]),
343340
);
344341
$jwe = $builder
345342
->create()

0 commit comments

Comments
 (0)