Repository navigation
feat(package-apps): per-user subdomains on the package-app domain #1395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
deae977
feat(package-apps): serve hosted package apps from per-user subdomains
cursoragent 36bc4e5
feat(identity): restrict usernames to DNS labels (no underscores)
cursoragent ec7673e
feat(deploy): wildcard route and DNS for per-user package-app subdomains
cursoragent c79c255
docs: per-user package-app subdomains, __Host- cookie, decision 0017
cursoragent bebcc4b
fix(identity): two-tier username validation for legacy underscore acc…
cursoragent 4ebdb63
fix: address CodeRabbit review findings
cursoragent 8780b9c
fix: strict platform-account usernames, DNS conflict ordering, no POS…
cursoragent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
74 changes: 74 additions & 0 deletions
74
docs/contributing/decisions/0017-per-user-package-app-subdomains.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| # 0017: Per-user subdomains for hosted package apps | ||
|
|
||
| - **Status:** accepted | ||
| - **Date:** 2026-08-11 | ||
|
|
||
| ## Context | ||
|
|
||
| Hosted package apps execute author-supplied HTML and JavaScript. Production | ||
| already isolates them from the first-party app origin via a separate registrable | ||
| domain (`PACKAGE_APP_BASE_URL`, `kodyapps.dev`) and credential stripping, but | ||
| every owner's apps still shared one origin on that domain. One user's package | ||
| could reach another user's `kody_pkg_session`-authorized endpoints from the | ||
| browser — a smaller blast radius than first-party access, but not zero. | ||
|
|
||
| Alternatives considered: | ||
|
|
||
| - **Stay on one shared package-app origin.** Simpler DNS and routing, but | ||
| user-to-user browser isolation remains incomplete. | ||
| - **Per-package subdomains** (`{kodyId}.kodyapps.dev`). Stronger same-owner | ||
| isolation, but multiplies DNS/certificate surface and complicates the handoff | ||
| and `packageContext` contract for every package. | ||
| - **Path-only isolation with stricter CSP on package apps.** Would still leave | ||
| same-origin cookie and storage sharing; CSP cannot be applied to author code | ||
| without breaking real apps. | ||
|
|
||
| Usernames had allowed underscores, which are invalid in DNS labels and would | ||
| block `{username}.kodyapps.dev` for affected accounts. | ||
|
|
||
| ## Decision | ||
|
|
||
| Serve production hosted package apps on **per-user subdomains** of the | ||
| package-app apex: | ||
|
|
||
| - Public URL shape: `https://{username}.kodyapps.dev/packages/{kodyId}/{path}` | ||
| - The apex (`kodyapps.dev`) serves no package code: `/` redirects to the app | ||
| origin; legacy `/@user/packages/...` paths redirect to the owning subdomain; | ||
| everything else `404`s. | ||
| - The app-origin path `/@{username}/packages/...` remains the authenticated | ||
| entry point and redirects into the handoff on the owner's subdomain. | ||
| - Package-app session cookies on secure requests use the | ||
| `__Host-kody_pkg_session` name so browsers reject any variant with a `Domain` | ||
| attribute (cookie-tossing defense before Public Suffix List entry). Insecure | ||
| local HTTP keeps plain `kody_pkg_session`. | ||
| - Serving requires session account username == subdomain label == path owner | ||
| (fixation defense). | ||
| - New and changed usernames are strict DNS labels (lowercase alphanumeric + | ||
| hyphens; underscores banned). Recognition of stored usernames stays lenient | ||
| (two-tier validation) so legacy underscore accounts keep display names, public | ||
| lookup, and inbound email routing; they must rename before hosted apps work | ||
| (the app origin answers their package-app entry with a `409` rename prompt). | ||
| - `packageContext.appBasePath` on a subdomain is `/packages/{kodyId}` (no | ||
| `/@{username}` prefix); inline non-production serving keeps the path-based | ||
| mount. Well-behaved packages that use `hostedUrl` / `appBasePath` stay | ||
| transparent. | ||
| - Untrusted markdown refuses `/packages/...` links on any host in addition to | ||
| `/@...`. | ||
| - **Same-user package-to-package isolation is deliberately deferred:** two | ||
| packages of one owner still share that owner's subdomain origin. | ||
| - **Operational follow-up:** submit `kodyapps.dev` to the Public Suffix List | ||
| (`_psl` TXT record + PR to publicsuffix/list) for defense-in-depth. | ||
|
|
||
| ## Consequences | ||
|
|
||
| - User-to-user browser isolation for hosted apps is complete; same-owner | ||
| cross-package reachability remains an accepted residual risk (documented in | ||
| [`security.md`](../security.md)). | ||
| - Production deploys require wildcard DNS and a `*.kodyapps.dev/*` Worker route | ||
| (see [`setup-manifest.md`](../setup-manifest.md)). | ||
| - Username renames become mandatory for underscore holders before subdomain | ||
| hosting works. | ||
| - `parsePackageSearchIdentity`, status probes, and author docs must recognize | ||
| both subdomain URLs and legacy path shapes during transition. | ||
| - Revisit per-package subdomains only if same-owner isolation becomes a reported | ||
| abuse vector or a product requirement. |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.