Skip to content

Feat: Add config slack app - #118

Merged
liamburja merged 1 commit into
feat/97-alertas-canal-slack-incoming-webhook-block-kitfrom
feat/97-alertas-canal-slack-incoming-webhook-block-kit-app
Nov 27, 2026
Merged

liamburja merged 1 commit into
feat/97-alertas-canal-slack-incoming-webhook-block-kitfrom
feat/97-alertas-canal-slack-incoming-webhook-block-kit-app

Conversation

@liamburja

@liamburja liamburja commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds the GitOps Slack app's /gitops command, so people can connect Slack channels to their organization's alerts from Slack. Alerts are still created in GitOps.

How it works:

  1. Install the app: an organization admin clicks Install on the Slack card under Apps, in the organization's channel settings. This is OAuth with only the commands scope, so Slack shows no channel picker. The workspace is then linked to that organization, once per workspace.
  2. /gitops login: GitOps replies with a private link that expires in 10 minutes. The user signs in to GitOps (password or Google) and confirms. Their Slack user is then linked to their GitOps account, once per person.
  3. /gitops channel: opens a Slack modal asking for a name and a message language. Pick the channel in Slack then opens Slack's own channel picker in the browser; this is the only way Slack issues an Incoming Webhook. GitOps saves the channel in the organization with its webhook, posts a test message, and ends on a "Back to Slack" page.
  4. /gitops status and /gitops help.

Channels connected this way are normal slack channels. They use the same transport, the same encryption and the same failure handling, and alerts select them as usual. Project alerts can use them because they are organization channels.

Other changes:

  • Apps section in Channels (organization only): cards in the same style as the channel type cards, for Slack and for Google Chat (coming soon).
    • An installed app shows Connected and only Disconnect, which asks for confirmation in a modal.
    • An app that isn't installed shows Not installed and Install.
    • The cards use a generic AppCardData, so Google Chat only needs to add its own card and actions.
  • GitOps Settings → Slack:
    • the manifest now includes the commands scope, the /gitops slash command and the interactivity URL;
    • the page shows the status of the command and the step for the Signing Secret.
  • Docs: README.md, CLAUDE.md, .env.example and .github/copilot-instructions.md.

Related issue

Part of #97

Change type

  • Bug fix
  • Feature
  • Documentation
  • Refactor
  • Security or permissions
  • Tests or tooling

Verification

  • bun run check
  • bun run lint
  • bun run test (995 tests)
  • bun run format:check: the files in this PR pass Prettier. The check still fails on files this PR doesn't touch, such as README.md and CLAUDE.md, which already failed before.
  • UI tested manually, if applicable: to do against a real Slack workspace through a tunnel (steps below).

I also checked the CSRF guard on the production build (node build):

  • a cross-site form gets 403;
  • a form without Origin gets 403;
  • a same-origin form passes;
  • /api/slack/commands and /api/slack/interactions pass;
  • /api/slack/commandsx gets 403.

Review notes

Environment variables

  • New optional variable: SLACK_SIGNING_SECRET, the app's Signing Secret. /gitops is enabled only when it is set together with SLACK_CLIENT_ID and SLACK_CLIENT_SECRET. Without it, Add to Slack keeps working as before.
  • Existing Slack apps must be updated, or created again from GitOps Settings → Slack, to get:
    • the commands scope;
    • the /gitops command, pointing to <ORIGIN>/api/slack/commands;
    • interactivity, pointing to <ORIGIN>/api/slack/interactions.
  • Slack calls those URLs, so the installation must be reachable from the internet over https.

Data

  • New GitDB entity slack_workspaces: one row per Slack team, linked to one organization. Installing the same workspace from another organization is refused with slack_workspace_taken. The row stores the bot token, encrypted with GITDB_ENCRYPTION_KEY (ChannelCipher, purpose slack-bot-token). The token is only used for views.open, to open the modal.
  • Linked Slack users: stored in user.authProviders as { provider: 'slack', providerId: '<team>:<user>' }, the same way as the Google sub.
  • No migration is needed.

Security

  • CSRF: Slack posts form-encoded requests without an Origin header, which SvelteKit's CSRF check rejects in production (in dev the check is off). The framework check is disabled (csrf.trustedOrigins: ['*']) and the same rule now runs in hooks.server.ts (csrfGuard, #lib/server/csrf). Only /api/slack/commands and /api/slack/interactions are exempt (CSRF_EXEMPT_PATHS). Like the framework, the check only runs in production. Please review this part closely.
  • Slack endpoints: they have no session and no API key. They verify X-Slack-Signature with HMAC-SHA256 over the raw body, a constant-time comparison and a 5-minute window, and refuse anything without a valid signature.
  • Acting as the user:
    • every command runs as the GitOps user linked to the Slack user, and disabled users are refused;
    • organization:notifications:create is checked on every command, every form submission and again in the OAuth callback;
    • writes run under runWithActor, so GitDB commits carry the linked user;
    • linking requires a signed-in session and membership of the workspace's organization (canViewOrganization); a Slack user can only be linked to one GitOps account.
  • Pick-the-channel link: it is signed and expires in 10 minutes. The OAuth flow is bound to the Slack team and user, and the callback compares them with team.id and authed_user.id from Slack. A forwarded link fails with slack_wrong_workspace.
  • Session handling in the callback: /notifications/slack/callback now accepts requests without a session. Only flows started from Slack (kind: 'command') can finish without one. Add to Slack and the app install still require the same session that started them.
  • Return after login: /notifications/slack/link is remembered in a gitops_return_to cookie (10 minutes, httpOnly) so the password and Google logins come back to it. Only that path is allowed (safeReturnPath); every other login still lands on /.
  • No secrets in replies or logs: Slack replies contain no tokens or webhooks, logs only record error codes, and user-provided names are escaped for Slack.

Testing locally

  1. Use a tunnel, because Slack must reach the server: cloudflared tunnel --url https://localhost:5173 --no-tls-verify.
  2. Start dev with DEV_HTTPS=true and __VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS=.trycloudflare.com.
  3. Create the app from <tunnel>/gitops-settings/slack and put the three Slack variables in .env.
  4. Install the app from the organization's channel settings, then run /gitops login, /gitops channel and /gitops status.

Known limitations and follow-up

  • /gitops channel creates organization channels only. Project channels from Slack are planned for later. Add to Slack from GitOps already supports projects.
  • Channel languages are only es and en.
  • Self-hosted installations still create their own Slack app. A central broker is pending a team decision.
  • Planned follow-up: move Apps to its own tab in the alert settings, and add Google Chat as the next provider.
  • The gitops-web docs for /gitops are on feat/97-alertas-canal-slack-incoming-webhook-block-kit-app-doc in gitops-web.

🤖 Generated with Claude Code

@liamburja
liamburja merged commit 18c05d5 into feat/97-alertas-canal-slack-incoming-webhook-block-kit Nov 27, 2026
1 check passed
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