Skip to content

feat!: namespace store cookies per client (parked) - #3403

Closed
tada5hi wants to merge 1 commit into
masterfrom
feat/per-client-session-isolation
Closed

tada5hi wants to merge 1 commit into
masterfrom
feat/per-client-session-isolation

Conversation

@tada5hi

@tada5hi tada5hi commented Aug 5, 2026 •

Copy link
Copy Markdown
Collaborator

Parked draft. Held pending the console credential decision in plan 088. If the consoles move to an opaque session identifier, namespacing JWT cookies is largely moot, so this should not be built on until that is settled.

The server-side half of the original stack was split out and is mergeable on its own as #3404.

What this does

Cookies are per origin, and the hosted auth pages share theirs with everything server-core serves, so every surface used one set of tokens: the account console adopted whatever login came before it, and its own tokens were readable by the next surface. Locally it is broader still, since cookies ignore the port.

The store takes a cookiePrefix and writes <prefix>.<name>. Bare names are the IdP's own SSO session (owned by the hosted auth pages, which are the IdP surface rather than a client); a prefixed set belongs to one application.

. and not : because RFC 6265 defines a cookie name as an RFC 2616 token, whose separator set includes :. The prefix is the client name, which an app knows before it has a session, never the id, which it cannot know until it has one.

Shadow-clearing follows the prefix and deliberately leaves the bare tier alone: clearing it would sign the visitor out of the IdP as a side effect of loading an app. Pinned by a test verified to fail if the implementation reverts.

Why it is parked

Header size. Namespacing fixes sharing by making the IdP origin carry two cookie sets instead of one, so header weight roughly doubles there: three JWTs plus a user blob per set, on every request including assets. Roughly 3-8 KB against nginx's default 8 KB buffer. An opaque session identifier collapses that to about 40 bytes and also makes the credential HttpOnly, which no amount of namespacing achieves.

Realm continuity. With its own namespace the account console no longer adopts the IdP session, so a visitor arriving from another application picks a realm once. An earlier revision read the realm from the bare tier; that could not work, because nothing writes that cookie (setRealm is called only by cleanup and hydration, while introspection writes realm.value directly by design). It was removed rather than carried along.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5924e24a-7f57-4e4c-9f82-6a88a75e302a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

authup

npm i https://pkg.pr.new/authup@3403

@authup/client-account-console

npm i https://pkg.pr.new/@authup/client-account-console@3403

@authup/client-admin-console

npm i https://pkg.pr.new/@authup/client-admin-console@3403

@authup/client-auth-console

npm i https://pkg.pr.new/@authup/client-auth-console@3403

@authup/server-core

npm i https://pkg.pr.new/@authup/server-core@3403

@authup/access

npm i https://pkg.pr.new/@authup/access@3403

@authup/client-web-kit

npm i https://pkg.pr.new/@authup/client-web-kit@3403

@authup/client-web-kit-theme

npm i https://pkg.pr.new/@authup/client-web-kit-theme@3403

@authup/client-web-nuxt

npm i https://pkg.pr.new/@authup/client-web-nuxt@3403

@authup/client-web-theme

npm i https://pkg.pr.new/@authup/client-web-theme@3403

@authup/core-http-kit

npm i https://pkg.pr.new/@authup/core-http-kit@3403

@authup/core-kit

npm i https://pkg.pr.new/@authup/core-kit@3403

@authup/core-realtime-kit

npm i https://pkg.pr.new/@authup/core-realtime-kit@3403

@authup/errors

npm i https://pkg.pr.new/@authup/errors@3403

@authup/i18n

npm i https://pkg.pr.new/@authup/i18n@3403

@authup/kit

npm i https://pkg.pr.new/@authup/kit@3403

@authup/server-adapter-kit

npm i https://pkg.pr.new/@authup/server-adapter-kit@3403

@authup/server-adapter-node

npm i https://pkg.pr.new/@authup/server-adapter-node@3403

@authup/server-adapter-socket-io

npm i https://pkg.pr.new/@authup/server-adapter-socket-io@3403

@authup/server-adapter-web

npm i https://pkg.pr.new/@authup/server-adapter-web@3403

@authup/server-kit

npm i https://pkg.pr.new/@authup/server-kit@3403

@authup/server-test-kit

npm i https://pkg.pr.new/@authup/server-test-kit@3403

@authup/specs

npm i https://pkg.pr.new/@authup/specs@3403

commit: 430501b

Cookies are per origin, not per application, and the hosted auth pages share
their origin with everything else server-core serves. So every surface there
used one set of tokens: the account console adopted whatever login came
before it, and its own tokens were readable by the next surface on the
origin. Locally it is broader still, because cookies ignore the port, so an
app on localhost:3000 shares the jar with the IdP on :3001.

The store takes a `cookiePrefix`, writing `<prefix>.<name>`. That splits the
jar in two, and the tiers are told apart by the prefix alone:

- BARE names are the IdP's own SSO session, owned by the hosted auth pages.
  They are not a client, they are the IdP surface, and their session is what
  the prompt=none / select_account ladder reads.
- A PREFIXED set belongs to one application. Both consoles set it to their
  OAuth2 client name; any relying party embedding the kit should too.

`.` rather than `:` because RFC 6265 defines a cookie name as an RFC 2616
token, whose separator set includes `:`. Browsers accept it, proxies and
cookie libraries do not uniformly. The prefix is the client NAME, which an
application knows before it has any session, never the client id, which it
cannot know until it has one.

Clearing shadowed copies follows the prefix and deliberately leaves the bare
tier alone: clearing it would sign the visitor out of the IdP as a side
effect of loading an application.

One consequence is deliberate and unresolved: the account console no longer
adopts the IdP session, so a visitor arriving from another application picks
a realm once instead of being carried straight through. Seeding that from the
IdP session needs a carrier the store does not write today, because the realm
is set directly from introspection precisely to avoid persisting it. That is
tracked in plan 087 rather than guessed at here.

BREAKING CHANGE: store cookies written by an application configured with a
`cookiePrefix` use `<prefix>.<name>`. Existing bare cookies are not
migrated, because they cannot be attributed to an application, so every
prefixed application signs out once on upgrade. A consumer reading
`CookieName` values off the document directly must add the same prefix.
@tada5hi
tada5hi force-pushed the feat/per-client-session-isolation branch from 8835511 to 430501b Compare August 5, 2026 08:25
@tada5hi tada5hi changed the title feat!: isolate sessions and token attribution per client feat!: namespace store cookies per client (parked) Aug 5, 2026
@tada5hi tada5hi closed this Aug 19, 2026
tada5hi added a commit that referenced this pull request Sep 2, 2026
* fix(client-web-nuxt): forward every declared module option

`runtimeOptions` was a hand-written list of six fields, and the type it is
annotated with is `RuntimeOptions` itself (`ModuleOptions` is an alias of it),
so the list could only ever fall behind. It already had: `serverApiURL` is
declared and read by the plugin, yet never reached `runtimeConfig`, so setting
it under the `authup:` module key did nothing.

Spread the options instead. `defaults` is empty, so the spread is exactly the
declared surface, and a new option cannot be silently inert.

* feat(client-web-nuxt): allow namespacing the session cookies

The store cookies are written under fixed names (`access_token`,
`refresh_token`, ...) and the only scoping knob was `cookieDomain`. Widening
that domain delivers those names to every host under it, so any other authup
client reachable there writes the same names, the browser holds two records
under one, and a read takes the first. Each side then drives on, refreshes and
cleanup-revokes the other's tokens, which surfaces as being signed out on the
next page load. Observed in FLAME Hub, which widens the domain so a sibling
service can read the token on a file download, a top-level navigation that
cannot carry an `Authorization` header.

`cookiePrefix` prepends a namespace, verbatim, so `flame_` writes
`flame_access_token`. It goes in the plugin's own `cookieGet` / `cookieSet` /
`cookieUnset` rather than in `@authup/client-web-kit`, and that is total
rather than partial: `installStore` routes every read, write and unset through
those three, the two cleanup sweeps included, so they follow the prefix and
stop clearing a bare name that belongs to somebody else. The kit needs no
option of its own, which is also why this does not revive the parked kit-level
`cookiePrefix` of #3403: that one was about the consoles sharing the IdP
origin, where a second cookie set doubles header weight on every request.

Only a consumer supplying its own `cookieSet` can set a `Domain` at all, since
the kit assigns one nowhere, so in every cross-host collision the widening side
is the side that can prefix, and breaking name equality on one side is enough.

Two consequences are documented rather than coded around. The prefix is a
contract across the adopting app's own services, so a resource server of theirs
reading the cookie must read the prefixed name. And cookies written before the
prefix was set are afterwards neither read nor swept; an automatic sweep is
deliberately refused, because under a widened domain it would delete a
not-yet-migrated sibling's cookies, and on the IdP origin it would clear the
hosted auth pages' own SSO cookies, signing the visitor out as a side effect of
loading an app.

Closes #3527

* docs(client-web-nuxt): correct the cookie-prefix migration advice

Signing out after the switch clears the PREFIXED names, so it does nothing
about the bare ones, and `access_token` / `access_token_expire_date` carry a
maxAge derived from the access token's lifetime, so closing the browser does
not remove them either. Both halves of the previous sentence were wrong.

Sign out BEFORE setting the prefix and there is nothing stale to begin with.
For someone who already switched, name which leftovers are session cookies and
which pair expires on its own.
tada5hi added a commit that referenced this pull request Sep 2, 2026
… the hosted session (#3535)

Cookies ignore ports, so localhost:3010 and localhost:3000 are one host to the
browser. A console dev server started while a session from the hosted auth
pages is open seeds itself from that session's path-`/` token cookies and comes
up signed in, without running the flow under test.

The last open half of plan 098 D1; the #3403 half was closed as parked.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant