Repository navigation
WW-5848 Make the Boot session cookie attributes configurable - #2144
Open
Matefodao3636 wants to merge 1 commit into
Open
Matefodao3636 wants to merge 1 commit into
Matefodao3636 wants to merge 1 commit into
Conversation
Adds two struts.boot settings, read by BootSettings and applied by StrutsBootServer: - struts.boot.session.cookie.secure: true or false (default false) - struts.boot.session.cookie.sameSite: lax, strict, none or unset (default lax) The starter opens a plain HTTP listener, so the session cookie is sent without Secure, and SameSite=Lax was fixed in code. An application that runs behind an HTTPS reverse proxy can now set secure=true, and pick another SameSite value if it needs one. The defaults are unchanged: SameSite=Lax and no forced Secure. Values ignore case and surrounding spaces. Any other value, an empty one included, fails startup with a ConfigurationException that names the setting and the value. SameSite stays on Tomcat's cookie processor, as WW-5841 introduced it, so it remains the default for every cookie of the context that has no SameSite attribute of its own; Secure only reaches the session cookie. Tests cover both, and the boot-hello README and THREAT_MODEL.md describe it. Implemented with Claude Code, reviewed in two independent rounds by GPT and Gemini, and validated on Linux by GPT with the full project build. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.
Fixes WW-5848
Summary
Adds the two settings the ticket proposes, read by
BootSettingsand applied byStrutsBootServer:struts.boot.session.cookie.securefalsetrue,falsestruts.boot.session.cookie.sameSitelaxlax,strict,none,unsetAs with the other
struts.bootkeys, the value comes fromstruts.properties, and a--key=valueargument overrides it.Why
The starter opens a plain HTTP listener, so
JSESSIONIDis sent withoutSecure, and since WW-5841SameSite=Laxis fixed in code. An application that runs behind an HTTPS reverse proxy had no setting to getSecureon its session cookie. Now it setsstruts.boot.session.cookie.secure=true, and it can pick anotherSameSitevalue if it needs one.Behaviour
SameSite=Lax,HttpOnly, no forcedSecure.secureis applied throughSessionCookieConfig#setSecure, so it only reaches the session cookie.sameSitestays onRfc6265CookieProcessor#setSameSiteCookies, where WW-5841 put it. It is therefore still the default for every cookie of the context that has noSameSiteattribute of its own, andunsetmakes the processor add none. The README and the Javadoc say so, and tests pin it.ConfigurationExceptionthat names the setting and the value.sameSite=nonewithoutsecure=trueis accepted, becauseSecuremay be added by the proxy. The README states what has to hold at the browser.Set-Cookieheaders observed against the embedded Tomcat (session id replaced):Startup errors for invalid values:
Tests and docs
BootSettingsTest: 11 new tests covering the defaults, values from the file, argument over file, case and spaces, and invalid values from both sources.StrutsBootTomcatTest: 12 new tests that start the server on loopback and read the realSet-Cookieheader. They include cookies added by the application (new fixtureCookieProbeAction) and startup failure on invalid values.testSessionCookieHasSameSiteLaxbecametestSessionCookieDefaultsToSameSiteLaxWithoutSecure, which also assertsHttpOnlyand the absence ofSecure.apps/boot-hello/README.md: both keys in the settings table, plus the notes above.THREAT_MODEL.md§5: the defaults stay listed as framework-owned, now with the key that overrides each.Validation
1fcb942, andmvn verifyfinished with BUILD SUCCESS on all 30 modules. Of 5,313 tests, 5,312 passed and 1 was skipped (it needs a second network interface).testBaseDirIsOwnerOnly, which is skipped on Windows, ran and passed. That run predates the rewording of one README sentence; nothing else changed after it.bootmodule: 75 tests, 74 passed and 1 skipped (testBaseDirIsOwnerOnly); the module had 52 before the change. The 24 tests of this change were also run against the original code: 13 fail, 4 pass because they describe behaviour that already existed, and 7 do not compile because they call the new accessors. These Windows runs needed a local one-line workaround that is not in this PR (see the last note below).Notes for reviewers
sameSitefollows the ticket. The neighbouring key iscontext-path, sosame-sitewould also be consistent; it is easy to rename.struts.boot.session.cookie.samesite) are ignored, as before. The README now says so.1fcb942the starter does not start on Windows.StrutsBootServer#createBaseDirthrows "Cannot restrict the Tomcat base directory to its owner", becauseFile.setWritable(true, true)returnsfalsefor a directory there. It is unrelated to WW-5848 and probably deserves its own ticket.AI assistance
Disclosed following the ASF generative tooling guidance:
The change contains no third-party material; it only extends code already in the module.
🤖 Generated with Claude Code