Skip to content

Return people to the calling app after they connect a connector account - #481

Merged
tnkuehne merged 1 commit into
mainfrom
app-connect-return
Nov 29, 2026
Merged

tnkuehne merged 1 commit into
mainfrom
app-connect-return

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Problem

When an app calls a connector template and the person has not connected their account yet, the result carries connectUrl, the connector's own page. After connecting there, the person stays on the connector's page and has to find their way back to the app.

Change

The app just renders result.connectUrl.

  • On the way back to the app: where a connector (an app exporting UserConnection) called through the app's binding links to its own host as connectUrl (any path), AppService.invoke replaces it with a link on the app's own host, /.widefleet/connect/<BINDING>. The runtime does not look at statuses; nested data and links another connector returned pass unchanged. Apps without web pages keep the connector's page. Connectors know nothing about the calling app.
  • When the person opens the link, the runtime takes the page they came from (Referer) as the destination if it is a page of this app, otherwise the app's start page; checks the connector's access groups; has the connector's UserConnection prepare a single-use sign-in ticket for that destination; checks the launch URL as "My connections" does; and redirects with no-store and no-referrer. The connector decides what the person sees there: the sign-in, or its page telling an administrator what to set up.

After the sign-in the connector sends the person back to that page. When connecting cannot start or does not finish, they return with connectionError=access or failed. A connectionError from an earlier attempt is dropped. The path is handled before the app's assets and redirects.

UserConnection is private

The entrypoint decides where a person returns after connecting, so only Widefleet calls it: the control plane refuses grants on it, the runtime refuses app calls through existing grants, MCP refuses calls, and it does not appear in uploaded API documentation, the service catalog, the API reference or describe. "My connections" uses the same connection code.

Tests

  • connectionReturn unit tests.
  • Control plane: catalog, description and reference leave out UserConnection; grants on it are refused.
  • Runtime on workerd and celld (RUN_SERVICE_TESTS=1): the app link replaces any link to the connector's host whatever the status or path, an app without UserConnection keeps its own link, nested data and a passed-through link stay; the person returns to the page they came from (query kept, fragment and an earlier connectionError dropped); another site, an ambiguous path or no referrer leads to the start page; connectionError for an unknown binding, missing group (including a claimed group header) and a failing connector; refused calls through a UserConnection grant; unchanged app routes.

Templates follow in the next PR of the stack.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
widefleet-docs 82a0bfa Nov 29 2026, 12:43 PM

@tnkuehne
tnkuehne force-pushed the app-connect-return branch 8 times, most recently from ea25a7d to 82a0bfa Compare November 29, 2026 12:42
Where a connector called through an app's binding links to its own host as
connectUrl, the app receives a link on its own host instead. The runtime
serves that link: it checks the connector's groups, has the connector's
UserConnection prepare a single-use ticket whose destination is the page
the person came from, and redirects; the connector decides what the person
sees. Failures return to that page with connectionError set to access or
failed. Only Widefleet calls UserConnection; apps, MCP, the catalog and API
documentation never see it.
@tnkuehne
tnkuehne merged commit 6454d6a into main Nov 29, 2026
17 checks passed
@tnkuehne
tnkuehne deleted the app-connect-return branch November 29, 2026 13:00
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