Skip to content

CAMEL-23592: camel-itest - update ShiroOverJmsTest for renamed Shiro security headers#23592

Merged
apupier merged 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-23592-shiro-jms-test
May 28, 2026
Merged

CAMEL-23592: camel-itest - update ShiroOverJmsTest for renamed Shiro security headers#23592
apupier merged 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-23592-shiro-jms-test

Conversation

@oscerd
Copy link
Copy Markdown
Contributor

@oscerd oscerd commented May 28, 2026

Motivation

CAMEL-23592 (#23506) renamed three ShiroSecurityConstants header values from
non-Camel-prefixed (SHIRO_SECURITY_TOKEN, SHIRO_SECURITY_USERNAME,
SHIRO_SECURITY_PASSWORD) into the canonical Camel prefix
(CamelShiroSecurityToken etc.). The intent — quoting the upgrade-guide entry — is
that "these headers carry credentials and a serialized authentication token, so
filtering them at transport boundaries by default is particularly important."

The default JmsHeaderFilterStrategy (and similarly for CXF/HTTP) filters every
Camel* header (case-insensitive) on both inbound and outbound. So with the rename,
a trusted Shiro-over-JMS route that was passing the serialized token through JMS
suddenly loses that token at the JMS producer, the consumer-side ShiroSecurityPolicy
sees no token, throws an authentication failure exception, and the message lands on
the dead-letter mock.

ShiroOverJmsTest in camel-itest is exactly this pattern and started failing on
the 4.18.x backport PR (#23552):

mock://ShiroOverJmsTestError Received message count. Expected: <0> but was: <1>

The same regression is latent on main: CAMEL-23592 merged earlier today
(commit aeb5fd9d) and the post-merge
main CI run reported
success, but its incremental-build only ran tests for camel-shiro itself — camel-itest
was built but its tests were not executed. Anyone running
mvn -pl tests/camel-itest test -Dtest=ShiroOverJmsTest on main will reproduce
the same failure.

What this changes

This PR keeps the rename (the underlying security improvement) but updates the
integration test, and documents the new opt-in pattern users need to apply.

ShiroOverJmsTest

Adds a small subclass of JmsHeaderFilterStrategy (private to the test) that opts
the three Shiro security headers back through the transport boundary while leaving
every other Camel*-prefixed filter rule untouched:

private static final class ShiroFriendlyJmsHeaderFilterStrategy extends JmsHeaderFilterStrategy {
    @Override
    public boolean applyFilterToCamelHeaders(String headerName, Object headerValue, Exchange exchange) {
        if (isShiroSecurityHeader(headerName)) {
            return false; // allow through
        }
        return super.applyFilterToCamelHeaders(headerName, headerValue, exchange);
    }
    // applyFilterToExternalHeaders mirrors the same logic
    // isShiroSecurityHeader does a case-insensitive equals against the three constants
}
amq.setHeaderFilterStrategy(new ShiroFriendlyJmsHeaderFilterStrategy());

This demonstrates the exact configuration end-users need to keep Shiro-over-JMS
routes working post-CAMEL-23592.

4.21 upgrade guide

Extends the existing === camel-shiro - potential breaking change entry with the
new HeaderFilterStrategy opt-in pattern and a worked code example. Points to
ShiroOverJmsTest as a worked example.

Compatibility

  • Test only: no production code change.
  • Doc only: extends an existing upgrade-guide section, no schema/catalog
    regen needed.
  • No security regression: the new pattern is opt-in and scoped to three
    specific named headers — the default filter still blocks every other Camel*
    header at the JMS boundary.

Test plan

  • mvn -pl tests/camel-itest test -Dtest=ShiroOverJmsTest passes locally
    (was failing on the 4.18.x backport without this change).
  • Full reactor build from root succeeds: mvn clean install -DskipTests.
  • No regen artifacts touched (verified via git status post-build).

Follow-on

Once merged on main, the same fix needs to be cherry-picked into the
in-flight backport PRs:

  • #23552 — backport of CAMEL-23592
    to camel-4.18.x (currently red on this exact test).
  • A future backport to camel-4.14.x (when CAMEL-23592 is backported there).

Related


Claude Code on behalf of Andrea Cosentino

…security headers

After CAMEL-23592 the three Shiro security headers (SHIRO_SECURITY_TOKEN,
SHIRO_SECURITY_USERNAME, SHIRO_SECURITY_PASSWORD) carry their value in the
Camel* namespace (CamelShiroSecurityToken etc.). The default
JmsHeaderFilterStrategy filters every Camel* header at the transport
boundary, which is the intended behavior for untrusted producers but
strips the serialized authentication token from trusted Shiro-over-JMS
routes that previously relied on the old non-Camel-prefixed value
surviving the JMS round-trip.

ShiroOverJmsTest demonstrates the Shiro-over-JMS pattern and started
failing because the consumer-side policy could no longer read the token
from the message: the failed message went to the dead-letter mock
(expected 0, was 1). The test was passing on main only because its
incremental-build scope did not exercise camel-itest after the rename;
the regression is latent on main too.

- ShiroOverJmsTest: configure a small subclass of JmsHeaderFilterStrategy
  on the JMS component that opts the three Shiro security headers back
  in (returns false from applyFilterToCamelHeaders /
  applyFilterToExternalHeaders for those headers and delegates to super
  for everything else). This is the pattern end-users will need.
- 4.21 upgrade guide: extend the camel-shiro entry to document the new
  required HeaderFilterStrategy opt-in for trusted Shiro-over-transport
  routes, with a worked code example mirroring the one used in the test.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
@oscerd oscerd requested review from davsclaus and gzurowski May 28, 2026 08:21
@github-actions
Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

oscerd added a commit to oscerd/camel that referenced this pull request May 28, 2026
…security headers

After CAMEL-23592 the three Shiro security header values move into the
Camel* namespace (CamelShiroSecurityToken etc.). The default
JmsHeaderFilterStrategy filters every Camel* header at the transport
boundary, which is the intended behavior for untrusted producers but
strips the serialized authentication token from trusted Shiro-over-JMS
routes that previously relied on the old non-Camel-prefixed value
surviving the JMS round-trip.

ShiroOverJmsTest is exactly such a trusted Shiro-over-JMS route and
started failing on this backport branch's CI:

  mock://ShiroOverJmsTestError Received message count.
  Expected: <0> but was: <1>

(the consumer-side ShiroSecurityPolicy could no longer read the token
and the message ended up at the dead-letter mock). The same regression
exists latently on main; the matching fix is in PR apache#23592.

- ShiroOverJmsTest: configure a small subclass of JmsHeaderFilterStrategy
  on the JMS component that opts the three Shiro security headers back in
  (returns false from applyFilterToCamelHeaders /
  applyFilterToExternalHeaders for those headers, delegates to super for
  everything else). This is the pattern end-users will need.
- 4.18 upgrade guide: extend the camel-shiro entry to document the new
  required HeaderFilterStrategy opt-in for trusted Shiro-over-transport
  routes, with a worked code example mirroring the one used in the test.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
@github-actions
Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • docs
  • tests/camel-itest

⚙️ View full build and test results

oscerd added a commit to oscerd/camel that referenced this pull request May 28, 2026
…security headers

After CAMEL-23592 the three Shiro security header values move into the
Camel* namespace (CamelShiroSecurityToken etc.). The default
JmsHeaderFilterStrategy filters every Camel* header at the transport
boundary, which is the intended behavior for untrusted producers but
strips the serialized authentication token from trusted Shiro-over-JMS
routes that previously relied on the old non-Camel-prefixed value
surviving the JMS round-trip.

ShiroOverJmsTest is exactly such a trusted Shiro-over-JMS route and
was failing on this backport branch's CI:

  mock://ShiroOverJmsTestError Received message count.
  Expected: <0> but was: <1>

(the consumer-side ShiroSecurityPolicy could no longer read the token
and the message ended up at the dead-letter mock). The same regression
exists latently on main; the matching fix is in PR apache#23592, and PR apache#23552
applies it to the 4.18.x backport.

- ShiroOverJmsTest: configure a small subclass of JmsHeaderFilterStrategy
  on the JMS component that opts the three Shiro security headers back in
  (returns false from applyFilterToCamelHeaders /
  applyFilterToExternalHeaders for those headers, delegates to super for
  everything else). This is the pattern end-users will need.
- 4.14 upgrade guide: extend the camel-shiro entry to document the new
  required HeaderFilterStrategy opt-in for trusted Shiro-over-transport
  routes, with a worked code example mirroring the one used in the test.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
@apupier
Copy link
Copy Markdown
Contributor

apupier commented May 28, 2026

merging as it is fixing main branch

@apupier apupier merged commit f745392 into apache:main May 28, 2026
7 checks passed
oscerd added a commit that referenced this pull request May 28, 2026
…der constant names with Camel naming convention (#23552)

* CAMEL-23592: camel-shiro - align Exchange header constant names with Camel naming convention (#23506)

Renames the three Exchange header string values in ShiroSecurityConstants
that drive Shiro authentication (SHIRO_SECURITY_TOKEN,
SHIRO_SECURITY_USERNAME, SHIRO_SECURITY_PASSWORD) to CamelShiroSecurity<Name>,
following the convention used across the rest of the Camel component catalog
and matching the pattern established in CAMEL-23526 (camel-cxf), CAMEL-23522
(camel-mail), CAMEL-23461 (camel-aws-bedrock), CAMEL-23532
(camel-vertx-websocket / camel-atmosphere-websocket / camel-iggy), and
CAMEL-23576 (camel-jira).

- SHIRO_SECURITY_TOKEN: "SHIRO_SECURITY_TOKEN" -> "CamelShiroSecurityToken"
- SHIRO_SECURITY_USERNAME: "SHIRO_SECURITY_USERNAME" -> "CamelShiroSecurityUsername"
- SHIRO_SECURITY_PASSWORD: "SHIRO_SECURITY_PASSWORD" -> "CamelShiroSecurityPassword"

These headers carry credentials and a serialized authentication token, so
filtering them at transport boundaries by default is particularly important.

The Java field names are unchanged so routes referencing the constants
symbolically continue to work; routes using the literal string values must be
updated (documented in the 4.21 upgrade guide). No tests reference the
literal values, and the shiro adoc documentation references the constants
symbolically.

Tracker: CAMEL-23577

Reported by Claude Code on behalf of Andrea Cosentino

Signed-off-by: Andrea Cosentino <ancosen@gmail.com>

* CAMEL-23592: camel-itest - update ShiroOverJmsTest for renamed Shiro security headers

After CAMEL-23592 the three Shiro security header values move into the
Camel* namespace (CamelShiroSecurityToken etc.). The default
JmsHeaderFilterStrategy filters every Camel* header at the transport
boundary, which is the intended behavior for untrusted producers but
strips the serialized authentication token from trusted Shiro-over-JMS
routes that previously relied on the old non-Camel-prefixed value
surviving the JMS round-trip.

ShiroOverJmsTest is exactly such a trusted Shiro-over-JMS route and
started failing on this backport branch's CI:

  mock://ShiroOverJmsTestError Received message count.
  Expected: <0> but was: <1>

(the consumer-side ShiroSecurityPolicy could no longer read the token
and the message ended up at the dead-letter mock). The same regression
exists latently on main; the matching fix is in PR #23592.

- ShiroOverJmsTest: configure a small subclass of JmsHeaderFilterStrategy
  on the JMS component that opts the three Shiro security headers back in
  (returns false from applyFilterToCamelHeaders /
  applyFilterToExternalHeaders for those headers, delegates to super for
  everything else). This is the pattern end-users will need.
- 4.18 upgrade guide: extend the camel-shiro entry to document the new
  required HeaderFilterStrategy opt-in for trusted Shiro-over-transport
  routes, with a worked code example mirroring the one used in the test.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>

---------

Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
oscerd added a commit to oscerd/camel that referenced this pull request May 28, 2026
…security headers

After CAMEL-23592 the three Shiro security header values move into the
Camel* namespace (CamelShiroSecurityToken etc.). The default
JmsHeaderFilterStrategy filters every Camel* header at the transport
boundary, which is the intended behavior for untrusted producers but
strips the serialized authentication token from trusted Shiro-over-JMS
routes that previously relied on the old non-Camel-prefixed value
surviving the JMS round-trip.

ShiroOverJmsTest is exactly such a trusted Shiro-over-JMS route and
was failing on this backport branch's CI:

  mock://ShiroOverJmsTestError Received message count.
  Expected: <0> but was: <1>

(the consumer-side ShiroSecurityPolicy could no longer read the token
and the message ended up at the dead-letter mock). The same regression
exists latently on main; the matching fix is in PR apache#23592, and PR apache#23552
applies it to the 4.18.x backport.

- ShiroOverJmsTest: configure a small subclass of JmsHeaderFilterStrategy
  on the JMS component that opts the three Shiro security headers back in
  (returns false from applyFilterToCamelHeaders /
  applyFilterToExternalHeaders for those headers, delegates to super for
  everything else). This is the pattern end-users will need.
- 4.14 upgrade guide: extend the camel-shiro entry to document the new
  required HeaderFilterStrategy opt-in for trusted Shiro-over-transport
  routes, with a worked code example mirroring the one used in the test.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
oscerd added a commit that referenced this pull request May 28, 2026
…der constant names with Camel naming convention (#23559)

* CAMEL-23592: camel-shiro - align Exchange header constant names with Camel naming convention (#23506)

Renames the three Exchange header string values in ShiroSecurityConstants
that drive Shiro authentication (SHIRO_SECURITY_TOKEN,
SHIRO_SECURITY_USERNAME, SHIRO_SECURITY_PASSWORD) to CamelShiroSecurity<Name>,
following the convention used across the rest of the Camel component catalog
and matching the pattern established in CAMEL-23526 (camel-cxf), CAMEL-23522
(camel-mail), CAMEL-23461 (camel-aws-bedrock), CAMEL-23532
(camel-vertx-websocket / camel-atmosphere-websocket / camel-iggy), and
CAMEL-23576 (camel-jira).

- SHIRO_SECURITY_TOKEN: "SHIRO_SECURITY_TOKEN" -> "CamelShiroSecurityToken"
- SHIRO_SECURITY_USERNAME: "SHIRO_SECURITY_USERNAME" -> "CamelShiroSecurityUsername"
- SHIRO_SECURITY_PASSWORD: "SHIRO_SECURITY_PASSWORD" -> "CamelShiroSecurityPassword"

These headers carry credentials and a serialized authentication token, so
filtering them at transport boundaries by default is particularly important.

The Java field names are unchanged so routes referencing the constants
symbolically continue to work; routes using the literal string values must be
updated (documented in the 4.21 upgrade guide). No tests reference the
literal values, and the shiro adoc documentation references the constants
symbolically.

Tracker: CAMEL-23577

Reported by Claude Code on behalf of Andrea Cosentino

Signed-off-by: Andrea Cosentino <ancosen@gmail.com>

* CAMEL-23592: camel-itest - update ShiroOverJmsTest for renamed Shiro security headers

After CAMEL-23592 the three Shiro security header values move into the
Camel* namespace (CamelShiroSecurityToken etc.). The default
JmsHeaderFilterStrategy filters every Camel* header at the transport
boundary, which is the intended behavior for untrusted producers but
strips the serialized authentication token from trusted Shiro-over-JMS
routes that previously relied on the old non-Camel-prefixed value
surviving the JMS round-trip.

ShiroOverJmsTest is exactly such a trusted Shiro-over-JMS route and
was failing on this backport branch's CI:

  mock://ShiroOverJmsTestError Received message count.
  Expected: <0> but was: <1>

(the consumer-side ShiroSecurityPolicy could no longer read the token
and the message ended up at the dead-letter mock). The same regression
exists latently on main; the matching fix is in PR #23592, and PR #23552
applies it to the 4.18.x backport.

- ShiroOverJmsTest: configure a small subclass of JmsHeaderFilterStrategy
  on the JMS component that opts the three Shiro security headers back in
  (returns false from applyFilterToCamelHeaders /
  applyFilterToExternalHeaders for those headers, delegates to super for
  everything else). This is the pattern end-users will need.
- 4.14 upgrade guide: extend the camel-shiro entry to document the new
  required HeaderFilterStrategy opt-in for trusted Shiro-over-transport
  routes, with a worked code example mirroring the one used in the test.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>

---------

Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants