Repository navigation
[#2962] Jakarta EE: secure-session-cookie.disabled is ignored in Faces Production mode - #2963
AndrewG10i wants to merge 4 commits into
Conversation
- 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.
|
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. |
Ah, yes, makes total sense! I just went with the first testing option GPT suggested to confirm the regression and verify the fix. |
ToniAdreal
left a comment
There was a problem hiding this comment.
I independently verified this fix against current main (0b3f11f).
The diagnosis in #2962 is correct. On main, EnvironmentLoaderListener.java:178-182 reads (!disabled && !hasFacesContext()) || !Faces.isDevelopment(), so with disabled=true in Faces Production mode the trailing !Faces.isDevelopment() is true and setSecure(true) still runs. The regrouped condition !disabled && (!hasFacesContext() || !Faces.isDevelopment()) fixes exactly that case. I checked the other three quadrants as well. Disabled=false with no Faces context still enforces secure, disabled=false in Production still enforces secure, and disabled=false in Development still skips it. Default Production behavior is preserved.
The new unit test covers all four quadrants, and productionHonorsOptOut is a real regression test. Under the old condition it would call setSecure(true) and fail the never() verification, under the new one it passes. The verifyNoInteractions() assertion also pins down that the opt-out short-circuits before any Faces call. I also checked the only other isDevelopment() use in the module, SslFilter.computeEnabled(), and it uses a plain if/else, so this precedence shape does not recur there.
One non-blocking note: the PR description still describes the removed ShiroSessionCookieIT integration tests and the mvn verify command. Since those were replaced by the unit tests, updating the description would keep the record accurate.
Caveat: I have no JDK on this machine, so I did not execute the tests locally. I am relying on the Jenkins PR-merge check, which is green at this head.
Summary
Fixes #2962: [Bug] Jakarta EE: secure-session-cookie.disabled is ignored in Faces Production mode
This PR fixes an issue in
EnvironmentLoaderListenerwhere theorg.apache.shiro.ee.secure-session-cookie.disabled=trueconfiguration 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
Secureattribute on the servlet container's session cookie.Changes
EnvironmentLoaderListenerso the explicit opt-out applies regardless of the Jakarta Faces project stage.ShiroSessionCookieITto verify the behavior using two Production deployments with container-managed sessions.CreateSessionServlettest fixture that creates an HTTP session usingrequest.getSession(true).Set-Cookieheaders and verify that:JSESSIONIDcookie includes theSecureattribute.org.apache.shiro.ee.secure-session-cookie.disabled=true, Shiro does not force theSecureattribute.Testing
Verified the regression before and after the fix:
Executed from the repository root:
Contribution checklist
Fixes #2962to link and close the issue upon merge.mvn verifycompleted successfully.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.