Skip to content

feat(connectors): create the Slack app from a prefilled manifest - #162

Merged
nixuuu merged 1 commit into
devfrom
feat/slack-app-manifest
Nov 5, 2026
Merged

nixuuu merged 1 commit into
devfrom
feat/slack-app-manifest

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Every Canopy installation can now connect Slack in one click. All installations share one fixed OAuth redirect URL.

One-click Slack app

  • "Create the Slack app" opens api.slack.com/apps?new_app=1&manifest_json=…, prefilled with name, description, the fixed redirect URL and all 30 Slack MCP user scopes.
  • "Use an existing Slack app" lets colleagues paste the client ID and secret from the app's owner. Nobody adds redirect URLs.
  • "Copy manifest" is available as a fallback.
  • Token rotation stays off: Slack never lets you turn it off again, and it is untested live.

Fixed redirect

  • Registered apps (Slack, GitHub OAuth apps) use https://itsoltech.github.io/canopy/oauth/callback, a static page built from site/oauth/ by the new Pages workflow.
  • The gateway sends that URL in both the authorize request and the token exchange. PKCE S256 stays required.
  • state carries the way back (<nonce>.w.<base64url callback> for web, <nonce>.d for desktop). The gateway stores a hash of the whole state, so a foreign callback never matches.
  • CANOPY_OAUTH_REDIRECT_URL overrides the URL.
  • Apps saved before this change keep their own callback.

The redirect page

  • It only forwards to an http(s) target whose path is exactly /api/connectors/oauth/callback, with no credentials.
  • It sends no referrer, has a hash-only CSP and no third-party scripts, and removes the query from history.

Desktop

  • canopy://oauth/callback reuses the existing desktopLink() parser, accepting only known keys and a desktop state.
  • The main process brings the window forward and finishes sign-in over the bridge.

Paste-code fallback

  • After 3 s the page offers "Copy code".
  • The connect dialog has a "Sign-in code" field.
  • The gateway validates the state exactly as the callback does.

Tests: connectors integration covers:

  • the manifest contents, with no secret anywhere;
  • the same redirect_uri in both OAuth steps;
  • forged callback, replayed code, and foreign or invalid pasted code;
  • the oauth-return format;
  • the desktop deep-link parser.

Pages: enabled for the repo (GitHub Actions source). The workflow publishes the redirect page when this merges.

Copy audit (docs/copy.md §8):

  • Buttons and tabs start with verbs.
  • Steps are imperative and under 20 words.
  • The internal-app requirement is stated once.
  • Every error ends with an action.
  • The ellipsis appears only on "Returning to Canopy…".

Canopy builds a Slack app manifest (user scopes of Slack's MCP tools, no
public distribution, no socket mode, org deploy or token rotation) and
opens Slack's "create app from manifest" page prefilled. The connect
dialog offers "Create the Slack app" with numbered steps and "Copy
manifest", or "Use an existing Slack app" with the owner's client ID and
secret. The scopes field starts with the same scopes.

Registered apps (Slack, GitHub OAuth apps) now use one fixed redirect
URL, a static page on the repository's GitHub Pages site
(CANOPY_OAUTH_REDIRECT_URL overrides it). The gateway puts the way back
into state: this installation's callback, or canopy://oauth/callback for
the desktop app, which hands the code to Settings → Connectors over the
desktop bridge. The page also offers the code to paste into the connect
dialog. The gateway still checks state as before: single-use,
owner-bound, short-lived, hashed as a whole.
@nixuuu
nixuuu marked this pull request as ready for review November 5, 2026 10:41
@nixuuu
nixuuu force-pushed the feat/slack-app-manifest branch from 3ac9fc5 to 6d53649 Compare November 5, 2026 10:41
@nixuuu
nixuuu merged commit f6d3ba1 into dev Nov 5, 2026
10 checks passed
@nixuuu
nixuuu deleted the feat/slack-app-manifest branch November 5, 2026 10:44
nixuuu added a commit that referenced this pull request Nov 5, 2026
…167)

The fixed sign-in redirect from #162
(`https://itsoltech.github.io/canopy/oauth/callback`) now covers every
OAuth connector where it is safe, not just apps registered by hand.

**Which connectors use it**
- Slack and GitHub OAuth apps, as before.
- Dynamic client registration (DCR) servers when their metadata
advertises PKCE S256: Notion, Linear, Atlassian, custom MCP servers, and
configured Microsoft 365 / Google Workspace endpoints. Their DCR
registration uses `redirect_uris = [fixed URL]`, and the authorize
request and token exchange send the same `redirect_uri`.

**Which keep the installation's own callback**
- Servers that don't advertise S256.
- Existing DCR registrations, until the user reconnects. On reconnect
the client is registered again, but only when the redirect or issuer
changed.
- Hand-registered apps saved with the installation callback.
- Everything, when `CANOPY_OAUTH_REDIRECT_URL` is set to the
installation's own callback.

**What every connector on the fixed redirect gets:** the desktop return
through `canopy://oauth/callback` and the paste-code fallback. The
gateway checks state as before: single-use, owner-bound, short-lived,
with the full-state hash.

**Tests:** gateway integration with the fake OAuth and local MCP
fixtures:
- a DCR server with S256 gets the fixed redirect;
- a server without S256 keeps the installation callback;
- an old registration keeps working, and reconnect migrates it;
- paste-code works for DCR;
- the desktop state routes to the deep link.

`docs/connectors.md` is updated.

Copy audit (`docs/copy.md` §8): no UI text changed.

**Still needs a live check:** DCR acceptance by real providers,
reconnect migration, opening the desktop deep link, and paste-code.
nixuuu added a commit that referenced this pull request Nov 5, 2026
…177)

After Slack sign-in, the redirect page at
`itsoltech.github.io/canopy/oauth/callback` stayed on "Returning to
Canopy…". It didn't open Canopy and showed no code to copy. The console
said: "Executing inline script violates the following Content Security
Policy directive 'script-src sha256-UQzX…'".

**Cause:** `build-site.ts` hashed the minified script, but the template
wraps it in indentation and a `;`. The browser hashes the exact text
between the tags, so the hashes differed and the script never ran.

**Fix**
- The build hashes the exact inline script and style bodies of the
finished page. `scripts/build-site.test.ts` checks the built page; it
fails on the old code.
- The page shows the code to copy right away. For the desktop app it
also shows an "Open Canopy" link, because a browser may refuse to open
the app without a click. The automatic return still runs first.
- The "Sign-in code" field also accepts the whole redirect address, or
just its query, as well as the code. The gateway checks `state` exactly
as before.

Copy audit (`docs/copy.md` §8):
- New "Open Canopy" link.
- The status after 3 s now names both ways back.
- The field hint is now "Paste the code from the sign-in page, or that
page's whole address."

Fixes: #162
nixuuu added a commit that referenced this pull request Nov 5, 2026
Stage 5 of 7 of shared configuration across linked computers. The design
is in `docs/linked-computers.md`.

**What changes**
- **Shared:**
- connected accounts: type, name, URL, transport, all-workers/all-bots
access and tool list;
- their credentials and headers, encrypted with each receiver's own key;
  - OAuth apps (client id and secret).
- **OAuth refresh:** a refresh replicates as a secret field change. A
computer that holds an older refresh token defers to the newer clock.
The rare "needs reconnect" race in the design is accepted.
- **Identity merge:** accounts with the same type, URL and account merge
and get aliases. A skill source's `credentialAccountId` maps through
those aliases.
- **Stays local:**
- per-computer status, last use and namespace, shown as "This computer";
  - worker grants, which come in stage 6;
  - bot grants, which stay with the bot's home.
- **Notices:** conflicts and deletions show a notice with Restore.
Delete keeps the encrypted credentials for the 90-day restore.
Disconnect revokes access.
- **Fixed OAuth redirect:** the behaviour from #162 and #167 is kept
(deep link, paste-code).

**Migration:** `0077_config_connectors` (`updated_at` on OAuth apps). No
new proto fields.

**Tests:** the connector integration suite (8 tests) covers:
- an account connected on A works on B without a reconnect;
- a refresh on A replicates to B, and B's older token loses;
- a rename conflict, and delete with Restore;
- secrets never reach history, logs or the BFF, and never cross a link
with sharing off;
- the source-account alias;
- owner scoping;
- the migration.

Copy audit (`docs/copy.md` §8):
- The obsolete local-only text is removed.
- Delete and disconnect are worded so each says what it does.
nixuuu added a commit that referenced this pull request Nov 5, 2026
Signing in to a connector no longer ends in a misleading "This code did
not work" error, and new Slack apps have MCP access turned on.

**What happened**
- **The dialog stayed open.** The sign-in page opened Canopy through
`canopy://`, and the deep link completed the sign-in. The Connect dialog
did not notice and kept asking for a code. Pasting that code (already
used) showed the generic "It works once and expires after 10 minutes.
Start sign-in again."
- **Slack MCP access was off.** Test then failed with HTTP 400, `-32600`
"App is not enabled for Slack MCP server access", because the generated
Slack app manifest did not set `settings.is_mcp_enabled`, so Slack
created the app with MCP access off.

**Fix**
- **Deep link:** when the deep link completes the sign-in, the open
Connect dialog closes and the account refreshes.
- **Pasting a code:** gives a specific result instead of one generic
error:
- "Already connected." when the code was used and the account is now
connected;
- separate messages for a code that was already used, an expired code, a
code from another window, and text that is not a sign-in code;
- provider rejections, with the redacted reason under **Show details**.
- **Security:** state stays single-use, owner-bound and valid for 10
minutes. A desktop BFF restart still needs a fresh sign-in.
- **Slack manifest:** gains `settings.is_mcp_enabled: true` (checked
against Slack's app manifest reference). The error from an app with MCP
access off has its own message: "Slack MCP access is off for this app.
Turn it on in the app's settings, then test again."
- **Setup docs:** the setup steps and `docs/connectors.md` explain how
to turn MCP access on for an existing app.

**Tests**
Gateway and BFF integration with a fake OAuth provider:
- a paste after the deep link completed;
- a valid code;
- an expired code;
- a code from another window;
- a malformed code;
- a provider error that shows its reason;
- the Slack MCP-off classification.

`check:tmp`: 1353 passed, 0 failed.

**Checked** in a browser with the real BFF and gateway, a fake provider
and the built bounce page, including a second completion of the same
sign-in. Light and dark, desktop, narrow and phone.

**Copy audit (§8):** each message gives the reason and the next action;
technical details stay collapsed.

Fixes: #162
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