Skip to content

[#2962] Jakarta EE: secure-session-cookie.disabled is ignored in Faces Production mode - #2963

Open
AndrewG10i wants to merge 3 commits into
apache:mainfrom
AndrewG10i:fix/2962-secure-session-cookie
Open

AndrewG10i wants to merge 3 commits into
apache:mainfrom
AndrewG10i:fix/2962-secure-session-cookie

Conversation

@AndrewG10i

@AndrewG10i AndrewG10i commented Nov 20, 2026 •

Copy link
Copy Markdown

Summary

Fixes #2962: [Bug] Jakarta EE: secure-session-cookie.disabled is ignored in Faces Production mode

This PR fixes an issue in EnvironmentLoaderListener where the org.apache.shiro.ee.secure-session-cookie.disabled=true configuration parameter was not respected when Jakarta Faces was running in Production mode (jakarta.faces.PROJECT_STAGE=Production).

Due to incorrect operator precedence in the existing condition, the Production check could bypass the explicit opt-out, causing Shiro to force the Secure attribute on the servlet container's session cookie.

Changes

  • Corrected the conditional expression in EnvironmentLoaderListener so the explicit opt-out applies regardless of the Jakarta Faces project stage.
  • Added ShiroSessionCookieIT to verify the behavior using two Production deployments with container-managed sessions.
  • Added a CreateSessionServlet test fixture that creates an HTTP session using request.getSession(true).
  • The integration tests inspect the raw Set-Cookie headers and verify that:
    • By default, the JSESSIONID cookie includes the Secure attribute.
    • With org.apache.shiro.ee.secure-session-cookie.disabled=true, Shiro does not force the Secure attribute.

Testing

Verified the regression before and after the fix:

  • Before the fix: The opt-out integration test failed, confirming the reported issue.
  • After the fix: Both integration test cases passed.

Executed from the repository root:

mvnw -B -ntp -pl :shiro-its-jakarta-ee -am verify `
  '-Dit.test=ShiroSessionCookieIT' `
  '-Dfailsafe.failIfNoSpecifiedTests=false' `
  '-Dtest=NoUnitTestsSelected' `
  '-Dsurefire.failIfNoSpecifiedTests=false' `
  '-DskipITs=false' `
  '-Dintegration.modes.skip=true' `
  '-Djapicmp-skip=true'

Contribution checklist

Licensing

AI Assistance

This contribution was prepared with the assistance of OpenAI Codex (GPT-6.2 Sol) for code analysis, implementation, and regression testing. The changes and test results were reviewed and validated by the contributor.

AndrewG10i and others added 3 commits November 20, 2026 20:26
- Group the Faces stage checks in EnvironmentLoaderListener so the explicit opt-out applies in Production. Previously, operator precedence let the Production check bypass the opt-out.
- Add ShiroSessionCookieIT to verify that the container-managed JSESSIONID cookie carries Secure by default and omits it when the opt-out is enabled.
@lprimak lprimak added this to the 3.1.0 milestone Nov 20, 2026
@lprimak

lprimak commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution, Andrew,

I removed the slow IT tests, as they added 2 deployments (x3 integration mode tests) which added much time to integration testing.
I also replaced the IT tests with fast unit tests.

@github-actions github-actions Bot added java Pull requests that update Java code tests labels Nov 20, 2026
@lprimak lprimak changed the title [#2962] - Fix for [Bug] Jakarta EE: secure-session-cookie.disabled is ignored in Faces Production mode [#2962] - Jakarta EE: secure-session-cookie.disabled is ignored in Faces Production mode Nov 20, 2026
@lprimak lprimak changed the title [#2962] - Jakarta EE: secure-session-cookie.disabled is ignored in Faces Production mode [#2962] Jakarta EE: secure-session-cookie.disabled is ignored in Faces Production mode Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

java Pull requests that update Java code tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Jakarta EE: secure-session-cookie.disabled is ignored in Faces Production mode

2 participants