Repository navigation
Conversation
* commit 'c9e066c5': Name the token type support in the deprecation of the loader factories fix: deprecate loader factories without a header checker manager factory # Conflicts: # src/Bundle/Services/JWELoaderFactory.php # src/Bundle/Services/JWSLoaderFactory.php # src/Library/Encryption/JWELoaderFactory.php # src/Library/Signature/JWSLoaderFactory.php
JWELoaderFactory and JWSLoaderFactory, in the library and in the bundle, no longer accept null as header checker manager factory; 4.3 deprecated it. Every loader they create now has a header checker manager, so even a loader without header checkers refuses a token whose "crit" lists a header parameter that nothing checks, a header parameter present in both the protected and the unprotected header, and a token type that the header checker manager factory does not support. An application that registered the library factories with autowiring now gets a container error instead of loaders that check nothing. The test cases give their factories a header checker manager factory with the token type support of their loaders, and the tests of the 4.3 deprecation are removed. Reported by Anthropic's OSS Scanner (ANT-2026-F6XYPNCA).
This was referenced Nov 8, 2026
…tever the change The Static Analysis job fails on 5.0.x for the reasons fixed on 4.3.x by #832: - PHPStan 2.3.7, shipped by the phpqa image since its rebuild of 2026-11-20, reports a mixed value as the condition of the ternaries of the processHeaders() methods of JSONFlattenedSerializer and JSONGeneralSerializer and of the if of MixedPublicAndPrivateKeys; - symfony/dependency-injection 8.2.0 declares the $config argument of ContainerBuilder::prependExtensionConfig() as array<string, mixed>, while ConfigurationHelper::updateJoseConfiguration() passes an array<mixed>. The baseline, generated by castor phpstan-baseline with the current image, gains those four entries and nothing else.
…factory-5.0.x 5.0.x is taken with the PHPStan baseline of #834. #779 reached 5.0.x through 4.3.x, so its merge is resolved as the description of this pull request plans: - the four factories keep the create() of this branch: the branch that throws when header checkers are requested without a header checker manager factory has no case left, and its import goes with it; - the #779 tests that need a factory without header checker manager factory are dropped: headerCheckersAreRefusedWithoutAHeaderCheckerManagerFactory and aLoaderWithoutHeaderCheckersNeedsNoHeaderCheckerManagerFactory in JWELoaderFactoryTest and JWSLoaderFactoryTest, NestedTokenLoaderFactoryTest, the two bundle tests that build a factory with null, and the autowired library factories of the test bundle with the two tests that use them; - theRequestedHeaderCheckersAreGivenToTheLoader stays.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second part of the follow-up of #768, for 5.0.0. It depends on #788 (4.3.x): this branch merges the two commits of #788, so that the merge-up of 4.3.x into 5.0.x stays free of conflicts. It stays a draft until #788 is merged. If #788 changes during the review, this branch is rebuilt on top of it.
The change
With #788 (4.3.0), creating a
JWELoaderFactoryor aJWSLoaderFactory, in the library or in the bundle, without a header checker manager factory triggers a deprecation. In 5.0.0 the argument is required:The four constructors take a non-nullable
HeaderCheckerManagerFactory, andcreate()always builds a header checker manager.Every loader these factories create therefore checks the header parameters, even without header checkers. It refuses a
critthat lists a parameter nothing checks, a parameter present in both the protected and the unprotected header, and a token type that the header checker manager factory does not support.In a Symfony application, registering the library factories with autowiring, the case of JWELoaderFactory and JWSLoaderFactory ignore the requested header checkers when they have no HeaderCheckerManagerFactory #768, now fails when the container is built:
The services of the bundle are not affected, since they always had a header checker manager factory.
A loader built directly still accepts a
nullheader checker manager.Tests
JWELoaderFactoryCriticalHeaderParameterTestandJWSLoaderFactoryCriticalHeaderParameterTest: a loader created without header checkers refuses a token whose protectedcritlistsexp, which nothing checks. Both fail on5.0.x, where the token is decrypted or verified, and pass here.EncryptionTestCase,SignatureTestCase,NestedTokenTestCaseand the nestedResultObjectsTestgive their factories a header checker manager factory with the token type support of their loaders. No other test needed a change: none of their tokens has acritor a duplicated header parameter.Verification
phpunit-11inphpqa:8.4: 2255 tests, no failure.5.0.xalone has 2253, with the same 4 skipped and 2 incomplete. The intermittentRSAKeysTest::loadPrivateRSAKeyFromMinimalValuesfailed once, then passed three times in a row.phpqa:8.4image.5.0.xand on this branch. The only differences are theTypeErrorwhen a factory is created withnull, in the library or in the bundle, and the cases that need such a factory. Everything else gives the same results: factories that have a header checker manager factory, the services of the bundle, the loaders of the configuration and kernel boot. With the library factories autowired, the application boots on5.0.xwith loaders that have no manager, and fails here with the container error above.Merge-up of #779
When #779 (4.2.7) reaches
5.0.xthrough4.3.x:create()of this branch. Theelseifbranch that throws when header checkers are requested without a header checker manager factory has no case left.headerCheckersAreRefusedWithoutAHeaderCheckerManagerFactoryandaLoaderWithoutHeaderCheckersNeedsNoHeaderCheckerManagerFactoryinJWELoaderFactoryTestandJWSLoaderFactoryTest;NestedTokenLoaderFactoryTest;null;TestBundle/Resources/config/services.php, without which the test container no longer compiles, and the two tests that use them.theRequestedHeaderCheckersAreGivenToTheLoaderstill applies.For the migration guide
JWELoaderFactoryandJWSLoaderFactory, in the library and in the bundle, require a header checker manager factory. Pass one that has the token type support of the loaders (JWETokenSupportorJWSTokenSupport), otherwise every token is refused with "Unsupported token type.". The loaders they create refuse critical header parameters that nothing checks, and header parameters given in both the protected and the unprotected header. In a Symfony application, use the services of the bundle (Jose\Bundle\JoseFramework\Services\JWELoaderFactory,JWSLoaderFactory) instead of registering the library factories.Found by the Anthropic OSS Scanner (ANT-2026-F6XYPNCA).