Skip to content

fix: deprecate loader factories without a header checker manager factory - #788

Merged
Spomky merged 3 commits into
4.3.xfrom
fix/loader-factories-require-header-checker-manager-factory
Nov 8, 2026
Merged

Spomky merged 3 commits into
4.3.xfrom
fix/loader-factories-require-header-checker-manager-factory

Conversation

@Spomky

@Spomky Spomky commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Follow-up of #768, fixed in 4.2.x by #779.

The change

JWELoaderFactory and JWSLoaderFactory, in the library and in the bundle, accept null as header checker manager factory. The loaders they create then check no header parameter at all, not even those listed in crit. Since #779 (4.2.7), asking such a factory for header checkers throws instead of ignoring them.

Creating one of these four factories without a header checker manager factory now triggers a deprecation, because the argument becomes required in 5.0.0:

Since web-token/jwt-library 4.3.0: Creating a "Jose\Component\Encryption\JWELoaderFactory" without a header checker manager factory is deprecated and will not be possible in 5.0.0: the loaders it creates check no header parameter, not even those listed in "crit". Pass a "Jose\Component\Checker\HeaderCheckerManagerFactory" that has the "Jose\Component\Encryption\JWETokenSupport" token type support.

The bundle factories report web-token/jwt-framework and name Jose\Bundle\JoseFramework\Services\HeaderCheckerManagerFactory. The message names the token type support because a header checker manager factory without it makes the loader refuse every token ("Unsupported token type."). Nothing else changes: the factories create the same loaders as before.

The 5.0.0 part, which makes the argument required, is #790 (draft) on 5.0.x.

Who gets the notice

  • Code that creates these factories with null, and applications that register the library factories with autowiring: autowiring passes null, because the header checker manager factory of the bundle is another class. That second case is the one JWELoaderFactory and JWSLoaderFactory ignore the requested header checkers when they have no HeaderCheckerManagerFactory #768 describes.
  • Not the bundle. Its services always get its own HeaderCheckerManagerFactory, and a test checks that the factories of the container trigger nothing.
  • In this repository, EncryptionTestCase, SignatureTestCase, NestedTokenTestCase and the nested ResultObjectsTest still create their factories with null, so they trigger the notice silently. Three ResultObjectsTest tests count the deprecations of the loader methods, so they now create their loader before counting. Moving the test cases to a header checker manager factory is left to 5.0.x. Here it would break the tests that fix: refuse header checkers that a loader factory cannot apply #779 added, which rely on a factory without one.

Tests

Test On 4.3.x With this PR
JWELoaderFactoryWithoutHeaderCheckerManagerFactoryTest::aFactoryWithoutHeaderCheckerManagerFactoryIsDeprecated fails, no notice passes
JWSLoaderFactoryWithoutHeaderCheckerManagerFactoryTest::aFactoryWithoutHeaderCheckerManagerFactoryIsDeprecated fails, no notice passes
bundle LoaderFactoriesWithoutHeaderCheckerManagerFactoryTest::theLoaderFactoriesWithoutHeaderCheckerManagerFactoryAreDeprecated fails, no notice passes
the same classes: aFactoryWithAHeaderCheckerManagerFactoryIsNotDeprecated (JWE, JWS), theLoaderFactoriesOfTheContainerAreNotDeprecated pass pass
the three ResultObjectsTest tests that count notices pass pass, with the loader created before counting

Verification

Found by the Anthropic OSS Scanner (ANT-2026-F6XYPNCA).

JWELoaderFactory and JWSLoaderFactory, in the library and in the bundle,
accept null as header checker manager factory. The loaders they create
then check no header parameter at all, not even those listed in "crit".

Creating one of these factories without a header checker manager factory
now triggers a deprecation: the argument becomes required in 5.0.0. The
bundle always passes its own, so its services are not affected.

The ResultObjectsTest classes create their loader before counting the
deprecations of the loader methods, so that the factories of the test
cases, still created without a header checker manager factory, do not
add to the count.

Reported by Anthropic's OSS Scanner (ANT-2026-F6XYPNCA).
@Spomky Spomky added this to the 4.3.0 milestone Nov 8, 2026
@Spomky Spomky added the bug label Nov 8, 2026
A header checker manager factory without the token type support of the
loader makes the loader refuse every token ("Unsupported token type.").
The deprecation now names the support to add, JWETokenSupport or
JWSTokenSupport, so that following it does not lead there.

Reported by Anthropic's OSS Scanner (ANT-2026-F6XYPNCA).
@Spomky
Spomky merged commit 5d3230b into 4.3.x Nov 8, 2026
18 checks passed
@Spomky
Spomky deleted the fix/loader-factories-require-header-checker-manager-factory branch November 8, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant