Skip to content

Adds Partitioned (CHIPS) support for the session cookie#1680

Merged
jakobvogel merged 4 commits into
mainfrom
feature/jvo/MIO-6543-Partitioned-Session-Cookie
Jul 14, 2026
Merged

Adds Partitioned (CHIPS) support for the session cookie#1680
jakobvogel merged 4 commits into
mainfrom
feature/jvo/MIO-6543-Partitioned-Session-Cookie

Conversation

@jakobvogel

Copy link
Copy Markdown
Member

Description

Adds an opt-in http.sessionCookie.partitioned (CHIPS) config that marks the client session cookie and its session-pin cookie with the Partitioned attribute. A partitioned cookie is stored and sent under a per-top-level-site partition, which lets the client session work inside a cross-site (third-party) iframe — e.g. an embedded support widget — that browsers (Safari ITP, Firefox TCP, Chrome 3PCD) would otherwise block or partition away.

  • Opt-in, defaults to false → behaviour is unchanged for every existing product unless it enables the flag. When false, setPartitioned(false) is a genuine no-op (the encoder only emits ; Partitioned when the flag is set), so no cookie changes on the wire.
  • Only honored by browsers on a Secure cookie; for the cross-site iframe use case it additionally has to be combined with SameSite=None.
  • Writing of the session and pin cookies is now funnelled through a single setSessionScopedCookie helper, so both consistently carry the SameSite, Secure and Partitioned attributes (the pin cookie must share the session cookie's partition, or pinning would break when CHIPS is enabled).

No breaking changes. Operational note when enabling: a partitioned session is scoped per top-level site (a session established under one embedding site is not shared with another) — this is the intended CHIPS behaviour.

Additional Notes

  • This PR fixes or works on following ticket(s): MIO-6543 (memoio support widget needs its session cookie to survive a cross-site iframe)
  • This PR is related to PR:

Checklist

  • Code change has been tested and works locally
  • Code was formatted via IntelliJ and follows SonarLint & best practices
  • Patch Tasks: Is local execution of Patch Tasks necessary?

Introduces an opt-in http.sessionCookie.partitioned config that marks the client
session cookie (and its pin cookie) with the Partitioned attribute. A partitioned
cookie is stored and sent under a per-top-level-site partition, which lets the
client session work inside a cross-site (third-party) iframe that browsers would
otherwise block or partition away - for example an embedded support widget. It is
only effective together with SameSite=None and a secure cookie; browsers ignore
the attribute otherwise.

The attribute defaults to false, so behaviour is unchanged unless a product opts
in. Writing of the session and pin cookies is now funnelled through a single
setSessionScopedCookie helper so both consistently carry the SameSite, security
and Partitioned attributes.

MIO-6543

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jakobvogel jakobvogel added the 🧬 Enhancement Contains new features label Jul 14, 2026
The session-value round-trip test strips the cookie attributes, so the
setSessionScopedCookie refactor's attribute handling was previously only verified
by code review. This asserts on the raw Set-Cookie that the session cookie is
still marked HttpOnly (the attribute now set inside the new helper) and that it
carries no Partitioned attribute while http.sessionCookie.partitioned defaults to
false - guarding both against an accidental regression.

MIO-6543

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds opt-in support for Partitioned (CHIPS) session cookies so client sessions can work reliably inside cross-site (third-party) iframes, while keeping default behavior unchanged.

Changes:

  • Introduces http.sessionCookie.partitioned config flag (default false) to emit the Partitioned cookie attribute for the session cookie and its pin cookie.
  • Refactors session/pin cookie writing through a shared helper to ensure consistent attributes (SameSite / Secure / Partitioned / HttpOnly).
  • Adds a regression test asserting the session cookie remains HttpOnly and is not partitioned by default.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/test/kotlin/sirius/web/http/WebContextTest.kt Adds regression test covering default (non-partitioned) session cookie attributes.
src/main/resources/component-065-web.conf Documents and adds http.sessionCookie.partitioned configuration default.
src/main/java/sirius/web/http/WebContext.java Adds config value and applies Partitioned attribute via new setSessionScopedCookie helper for session-related cookies.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/java/sirius/web/http/WebContext.java
A Partitioned (CHIPS) cookie is rejected outright by browsers unless it is also
Secure, and the attribute is only meaningful on a cookie that is actually sent
cross-site (SameSite=None). Emitting it unconditionally meant that enabling
http.sessionCookie.partitioned while the cookie was not secure (e.g. local HTTP
development under the default secure = IF_SSL, or a misconfigured secure = NEVER)
or not SameSite=None would produce an invalid cookie and break the session.

The Partitioned attribute is now only set when the resulting cookie is both
Secure and SameSite=None; otherwise it is silently skipped, so enabling the flag
can never produce an invalid cookie. Addresses the Copilot review on the PR.

MIO-6543

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@@ -1566,12 +1572,33 @@ private void buildClientSessionCookie() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: This has no usage left now, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, line 1533

@idlira idlira left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have done it the other way around, since this is needed in a HF: PR against main, later branch from your desired source tag and cherry-pick there, resolving any conflict that might arrive.
Another reason for that: since compile fail due to conflicts, test cases don't even run.

Brings origin/main into the branch so the PR can build the merged state and be
merged cleanly. The only conflict was in WebContext#buildClientSessionCookie,
where main's autoformat reformatted the setCookie(...) call that this branch
replaces with setSessionScopedCookie; resolved in favour of this branch's
version (setSessionScopedCookie for both the session and dated cookie paths).

The hotfix tag 106.0.1-hf-1 was cut on a6ff917 before this merge, so it remains
a clean 106.0.1 + delta unaffected by main's history.

MIO-6543

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jakobvogel
jakobvogel merged commit 850f962 into main Jul 14, 2026
3 checks passed
@jakobvogel
jakobvogel deleted the feature/jvo/MIO-6543-Partitioned-Session-Cookie branch July 14, 2026 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🧬 Enhancement Contains new features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants