Repository navigation
Require scoped application access across shared services - #55
Merged
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
widefleet-docs | 239c85b | Oct 20 2026, 02:11 PM |
This was referenced Oct 19, 2026
tnkuehne
marked this pull request as ready for review
October 19, 2026 22:44
tnkuehne
added a commit
that referenced
this pull request
Oct 20, 2026
Authenticated users can discover available organizations before choosing an application context. Without an explicit or saved selection, the only available organization is selected automatically. Browser sessions can choose at `/organizations`; API clients send `X-Widefleet-Organization`, and the CLI supports `widefleet organizations`, `--organization ID` and `PLATFORM_ORGANIZATION`. Multiple available organizations require a choice. Invalid or removed explicit or saved selections fail closed and can be repaired in the browser without signing out. The shared identity service owns selection, membership checks and role resolution. An optional fleet admission policy can only narrow those memberships. Standard installations remain restricted to their default fleet. `/me` includes the selected application context, and organization administrators do not become installation administrators. Browser forms and commands carry the organization displayed in their workspace. If another tab changes the session selection, the server rejects the stale write before issuing its principal; the browser explains the conflict and offers a page reload. This covers app, agent, access, workflow, member and settings mutations, including native forms without JavaScript. CLI deployment by name uses the shared authenticated request helper, retaining organization selection from app resolution through upload and deployment status. App links retain their path and query through the organization chooser, including recovery from a stale selection. Both enhanced and native forms use the validated destination returned by the server. Sign-in and selection share validation that rejects external destinations, including paths that become unsafe after URL normalization. Stacked on #55. This layer adds selection and admission contracts; it does not enable a complete hosted multi-organization deployment. Organization-specific login, directory configuration and deployment composition remain outside this change. Validation on the complete implementation stack: strict workspace checks, 464 regular Vitest tests, 17 authenticated CLI/API integration tests and 14 browser organization tests with and without JavaScript. The real CLI test deploys an app, creates a flat named preview and deploys it again with automatic and explicit organization selection. Browser tests create flat app and preview addresses while retaining stale-tab and app-link protection. Node and Cloudflare builds pass. All services and identities are local synthetic fixtures. Release-dependent documentation: #58 (publication blocked until the corresponding platform and CLI releases are published). <!-- greptile_comment --> <!-- greptile_summary --> <h2><a href="https://app.greptile.com/api/retrigger?id=83988827"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img alt="Retrigger" src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2" align="right"></picture></a><a href="https://app.greptile.com/mendra/github/widefleet/widefleet/-/pull/56"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img alt="View in Greptile" src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2" align="right"></picture></a>Confidence Score: 5/5 <sup><img alt="Tier: apex" title="Review tier: apex" src="https://greptile-static-assets.s3.amazonaws.com/badges/effort-apex.svg?v=3" height="12"></sup></h2> <!-- greptile-impact-verdict --> The PR appears safe to merge with the verified discovery and directory fixes in PR #57. <details open><summary><h3>Summary</h3></summary> Adds shared organization discovery and selection for browser sessions, API requests, and the CLI. - Authenticated requests now use an organization the person belongs to. - People can choose an organization and return to the page they wanted. - Workspace writes stop when another tab changes the selected organization. - The CLI can list organizations and send a selected one with requests. - Workflow replay tests coordinate branch entry instead of relying on timers. </details> <details open><summary><h3>Diagram</h3></summary> ```mermaid %%{init: {'theme': 'neutral'}}%% flowchart TD A["Browser session or API token"] --> B["Check identity and scope"] B --> C["Read memberships and apply fleet admission"] C --> D{"Organization chosen?"} D -->|No| E["Use the sole choice or show the chooser"] D -->|Yes| F["Check the selected membership"] E --> F F --> G{"Browser write matches the displayed organization?"} G -->|No| H["Reject with 409"] G -->|Yes or not a browser write| I["Issue the application context"] ``` </details> <!-- greptile_confidence_score:5 --> <sub>Reviews (7) · Last reviewed commit: ["Verify flat organization URLs through th..."](45d9e12) · [Reviewed by Greptile](https://www.greptile.com/?utm_source=greptile_review&utm_medium=github&utm_campaign=review_public&utm_content=widefleet/widefleet)</sub> <!-- /greptile_comment -->
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.
Application access requires an authenticated fleet and organization context. App creation, name resolution, listing, direct access, catalogs, grants, previews and member lookup stay within that context. Organization admins receive app permissions without installation-wide administration. Background actors retain the context across database connections, and preview-tree mutations reject cross-fleet relationships.
App names are unique per fleet. An optional stable fleet hostname suffix places apps and named previews directly under the shared
APP_DOMAIN: for suffixalpha, the appnotesis assignednotes-alpha.apps.example.test, with previewreview-notes-alpha.apps.example.test. Complete hostnames are reserved atomically and checked against DNS limits. The CLI accepts both supported preview layouts and prints the server-provided URL. Default installations retain their existing URLs and preview layout.Migration
0020_application_contextassociates existing fleets with the installation organization, replaces global app-name uniqueness and adds the optional hostname suffix. Persisted actor commands from older builds lack the required context and are rejected; drain outstanding actor-based Cloudflare operations before upgrading. This is the unreleased migration, updated in place. Explicit package exports and a runtime composition parameter allow extensions to reuse the shared implementation. Other administration and app-sign-in paths remain installation-scoped.Validation: 49 PostgreSQL application/context tests; 40 real CLI tests; 52 local workerd deployment tests, including app-service-created flat app and preview addresses, actual Dynamic Worker routing and isolated D1/R2 data. Strict types, format and lint passed; Node and Cloudflare builds also passed on the complete implementation stack. All services and fixtures were local.
Release-dependent documentation: #58, blocked until the corresponding platform and CLI releases are published. No production deployment or migration was performed.


Confidence Score: 5/5
The reviewed changes appear safe to merge; no new blocking issue was found.Summary
Application services now require an authenticated fleet context.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Authenticated request] --> B[Select fleet] B --> C[Check organization membership] C --> D[Build application context] D --> E[Fleet-scoped application services] D --> F[Background actor] F --> E E --> G[Create app or preview hostname] G --> H[Check DNS limits] H --> I[Reserve unique hostname]Reviews (2) · Last reviewed commit: "Use stable fleet suffixes for flat app a..." · Reviewed by Greptile