Skip to content

fix(desktop): let connector sign-in return to the desktop app - #161

Merged
nixuuu merged 1 commit into
devfrom
fix/desktop-oauth-callback
Nov 5, 2026
Merged

nixuuu merged 1 commit into
devfrom
fix/desktop-oauth-callback

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 5, 2026

Copy link
Copy Markdown
Member

In the desktop app, "Sign in with Notion" ended on "Untrusted desktop origin". The provider sends the system browser back to the app's callback. That top-level navigation comes from notion.com, so Sec-Fetch-Site: cross-site, and the desktop origin check in hooks.server.ts blocked it. The system browser also has no Electron cookie.

The exception covers only GET /api/connectors/oauth/callback:

  • the request must be a top-level navigation (Sec-Fetch-Mode: navigate, Sec-Fetch-Dest: document, when the browser sends them);
  • the Host must still match CANOPY_WEB_ORIGIN, so DNS-rebinding protection stays.

POST, fetch, other paths and a foreign Host are still blocked (403). GitHub and MCP OAuth share this callback. Pairing needs no exception.

The callback stays safe:

  • the gateway already makes state atomic and single-use, with a 10-minute TTL, bound to the owner and the account;
  • the BFF keeps the flow's binding itself instead of relying on the Electron cookie;
  • tokens stay in the gateway, and the result page shows fixed text without echoing what the provider sent.

After sign-in, a small result page says what happened and offers "Return to Canopy" (canopy://connectors, which brings the desktop window forward and refreshes the connectors). Errors and replayed states get clear text.

Tests:

  • BFF tests for the allow and block decisions;
  • a gateway integration test for single-use, owner-bound state with replay rejected.

Checked success, provider error and replay in light and dark, at 1280, 390 and 320 px.

Copy audit (docs/copy.md §8): the result page states one outcome, then what to do. Text is sentence case, buttons start with verbs, and provider errors are not echoed.

Fixes: #68

Allow only document GET navigations to the connector OAuth callback while preserving desktop Host checks and all other cross-site restrictions. Bind desktop flows to the BFF process so the system browser can complete sign-in without Electron cookies. Return fixed result copy and a credential-free app link, refresh connector settings, and cover state ownership, expiry and replay.

Fixes: #68
@nixuuu
nixuuu merged commit 49e9824 into dev Nov 5, 2026
9 checks passed
@nixuuu
nixuuu deleted the fix/desktop-oauth-callback branch November 5, 2026 09:46
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