Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/web-token-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:

- name: "Require web-token/*"
run: |
composer require --dev --no-update web-token/jwt-bundle:"^3.3.3"
composer require --dev --no-update web-token/jwt-bundle:"^3.3.3|^4.0"
composer require --dev --no-update spomky-labs/aes-key-wrap:"^7.0"
- name: "Install dependencies"
Expand Down
2 changes: 1 addition & 1 deletion Command/EnableEncryptionConfigCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Jose\Component\Core\AlgorithmManagerFactory;
use Jose\Component\Core\JWK;
use Jose\Component\Core\JWKSet;
use Jose\Component\Core\Util\Base64UrlSafe;
use Jose\Component\Encryption\Algorithm\ContentEncryptionAlgorithm;
use Jose\Component\Encryption\Algorithm\KeyEncryptionAlgorithm;
use Jose\Component\Encryption\JWEBuilder;
Expand All @@ -16,7 +17,6 @@
use Jose\Component\Signature\JWSBuilder;
use Jose\Component\Signature\JWSLoader;
use Lexik\Bundle\JWTAuthenticationBundle\Services\KeyLoader\KeyLoaderInterface;
use ParagonIE\ConstantTime\Base64UrlSafe;
use Symfony\Bundle\FrameworkBundle\Command\AbstractConfigCommand;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Console\Attribute\AsCommand;
Expand Down
2 changes: 1 addition & 1 deletion Command/MigrateConfigCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
use Jose\Component\Checker\ClaimCheckerManager;
use Jose\Component\Core\JWK;
use Jose\Component\Core\JWKSet;
use Jose\Component\Core\Util\Base64UrlSafe;
use Jose\Component\KeyManagement\JWKFactory;
use Jose\Component\Signature\JWSBuilder;
use Jose\Component\Signature\JWSLoader;
use Lexik\Bundle\JWTAuthenticationBundle\Services\KeyLoader\KeyLoaderInterface;
use ParagonIE\ConstantTime\Base64UrlSafe;
use Symfony\Bundle\FrameworkBundle\Command\AbstractConfigCommand;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Console\Attribute\AsCommand;
Expand Down
8 changes: 8 additions & 0 deletions DependencyInjection/LexikJWTAuthenticationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,14 @@ private function processWithWebTokenConfig(array $config, ContainerBuilder $cont
->replaceArgument(11, $config['access_token_verification']['encryption']['allowed_content_encryption_algorithms'])
->replaceArgument(12, $config['access_token_verification']['encryption']['keyset'])
;
} else {
$accessTokenLoaderDefinition
->replaceArgument(8, null)
->replaceArgument(9, null)
->replaceArgument(10, null)
->replaceArgument(11, null)
->replaceArgument(12, null)
;
}
}
}
Expand Down
17 changes: 11 additions & 6 deletions Resources/config/web_token_verification.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="lexik_jwt_authentication.web_token.clock" class="Symfony\Component\Clock\NativeClock" public="false">
</service>
<service id="lexik_jwt_authentication.access_token_loader" class="Lexik\Bundle\JWTAuthenticationBundle\Services\WebToken\AccessTokenLoader" public="false">
<argument type="service" id="Jose\Bundle\JoseFramework\Services\JWSLoaderFactory" />
<argument type="service" id="Jose\Bundle\JoseFramework\Services\JWELoaderFactory" on-invalid="null" />
Expand All @@ -21,20 +23,23 @@
<argument>null</argument> <!-- Encryption keyset -->
</service>
<service id="lexik_jwt_authentication.web_token.iat_validator" class="Jose\Component\Checker\IssuedAtChecker" public="false">
<argument>%lexik_jwt_authentication.clock_skew%</argument>
<argument>true</argument>
<argument key="$clock" type="service" id="lexik_jwt_authentication.web_token.clock" />
<argument key="$allowedTimeDrift">%lexik_jwt_authentication.clock_skew%</argument>
<argument key="$protectedHeaderOnly">true</argument>
<tag name="jose.checker.claim" alias="iat_with_clock_skew" />
<tag name="jose.checker.header" alias="iat_with_clock_skew" />
</service>
<service id="lexik_jwt_authentication.web_token.exp_validator" class="Jose\Component\Checker\ExpirationTimeChecker" public="false">
<argument>%lexik_jwt_authentication.clock_skew%</argument>
<argument>true</argument>
<argument key="$clock" type="service" id="lexik_jwt_authentication.web_token.clock" />
<argument key="$allowedTimeDrift">%lexik_jwt_authentication.clock_skew%</argument>
<argument key="$protectedHeaderOnly">true</argument>
<tag name="jose.checker.claim" alias="exp_with_clock_skew" />
<tag name="jose.checker.header" alias="exp_with_clock_skew" />
</service>
<service id="lexik_jwt_authentication.web_token.nbf_validator" class="Jose\Component\Checker\NotBeforeChecker" public="false">
<argument>%lexik_jwt_authentication.clock_skew%</argument>
<argument>true</argument>
<argument key="$clock" type="service" id="lexik_jwt_authentication.web_token.clock" />
<argument key="$allowedTimeDrift">%lexik_jwt_authentication.clock_skew%</argument>
<argument key="$protectedHeaderOnly">true</argument>
<tag name="jose.checker.claim" alias="nbf_with_clock_skew" />
<tag name="jose.checker.header" alias="nbf_with_clock_skew" />
</service>
Expand Down
2 changes: 1 addition & 1 deletion Services/WebToken/AccessTokenLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct(
) {
$this->jwsLoader = $jwsLoaderFactory->create(['jws_compact'], $signatureAlgorithms, $jwsHeaderChecker);
if ($jweLoaderFactory !== null && !empty($keyEncryptionAlgorithms) && !empty($contentEncryptionAlgorithms) && !empty($jweHeaderChecker)) {
$this->jweLoader = $jweLoaderFactory->create(['jwe_compact'], array_merge($keyEncryptionAlgorithms, $contentEncryptionAlgorithms), null, null, $jweHeaderChecker);
$this->jweLoader = $jweLoaderFactory->create(['jwe_compact'], array_merge($keyEncryptionAlgorithms, $contentEncryptionAlgorithms),headerCheckers: $jweHeaderChecker);
$this->continueOnDecryptionFailure = $continueOnDecryptionFailure;
}
$this->signatureKeyset = JWKSet::createFromJson($signatureKeyset);
Expand Down
7 changes: 2 additions & 5 deletions Tests/Functional/WebTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

use Jose\Component\Core\AlgorithmManager;
use Jose\Component\Core\JWK;
use Jose\Component\Core\Util\Base64UrlSafe;
use Jose\Component\Encryption\Algorithm\ContentEncryption\A128GCM;
use Jose\Component\Encryption\Algorithm\ContentEncryption\A256GCM;
use Jose\Component\Encryption\Algorithm\KeyEncryption\A128GCMKW;
use Jose\Component\Encryption\Algorithm\KeyEncryption\A256GCMKW;
use Jose\Component\Encryption\Compression\CompressionMethodManager;
use Jose\Component\Encryption\JWEBuilder;
use Jose\Component\Encryption\Serializer\CompactSerializer as JweCompactSerializer;
use Jose\Component\Signature\Algorithm\HS256;
Expand All @@ -20,7 +20,6 @@
use Lexik\Bundle\JWTAuthenticationBundle\Event\JWTInvalidEvent;
use Lexik\Bundle\JWTAuthenticationBundle\Events;
use Lexik\Bundle\JWTAuthenticationBundle\Response\JWTAuthenticationSuccessResponse;
use ParagonIE\ConstantTime\Base64UrlSafe;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand Down Expand Up @@ -337,9 +336,7 @@ private function buildJWS(array $claims, array $header, JWK $signatureKey): stri
private function buildJWE(string $payload, array $header, JWK $encryptionKey): string
{
$builder = new JWEBuilder(
new AlgorithmManager([new A256GCMKW(), new A128GCMKW()]),
new AlgorithmManager([new A256GCM(), new A128GCM()]),
new CompressionMethodManager([])
new AlgorithmManager([new A256GCMKW(), new A128GCMKW(), new A256GCM(), new A128GCM()]),
);
$jwe = $builder
->create()
Expand Down
Loading