Skip to content

Slack account linking in the app: one place, safety DM, People confirm moves to the app - #1902

Open
abhishek255 wants to merge 7 commits into
mainlinefrom
feat/slack-account-linking
Open

abhishek255 wants to merge 7 commits into
mainlinefrom
feat/slack-account-linking

Conversation

@abhishek255

@abhishek255 abhishek255 commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

What

Slack account linking in the app: one place (Account), a safety message after every link, and the People confirmation page moves from Code's own page to the app. Code API 1.33 (1.31 is taken on mainline, 1.32 by #1899; 1.30 is held by open changes). Pairs with the website PR #521.

Contract (all routes are web-app-only, full access; a refusal on the pending routes is an ANSWER, HTTP 200 { error })

Person's own links

  • GET /v1/dev/me/slack-links -> { links: [{ linkId, teamId, workspaceName, slackUserMasked, slackDisplayName?, linkedAt }] }. linkId is opaque. The raw Slack user id is never sent; slackUserMasked is display only and is not used in any address.
  • GET /v1/dev/me/slack-links/pending/{token} -> { workspaceName, slackDisplayName?, slackUserMasked, companyName, expiresAt, emailMatch } or { error }. emailMatch is "match" | "different" | "unknown", never the address; "unknown" when the Slack email scope is absent. Read only.
  • POST /v1/dev/me/slack-links/pending/{token}/confirm (empty body) -> { linked: true, workspaceName, slackDisplayName? } or { error }.
  • DELETE /v1/dev/me/slack-links/{teamId}/{linkId} -> { unlinked }. No Slack user id in the address.
  • error is one of expired_or_used, wrong_company, no_company, linked_to_other, already_yours, already_have_other, workspace_removed, not_set_up.

Company admin (owner or admin; a member is refused)

  • GET /v1/dev/company/slack/people -> { people: [{ personId, name, slackUserMasked, slackDisplayName?, linkedAt }] }.
  • DELETE /v1/dev/company/slack/people/{personId} -> { unlinked } (audited; keyed by personId).

People confirmation (F10), on the app

  • Token: {token} = <taskId>.<requestId>, two lower-case UUIDs joined by a dot. The app page is <web app>/app/people-confirm/{token}; treat the token as opaque.
  • GET /v1/dev/me/people-confirm/{token} -> { taskId, requestId, status: "pending", requestedBy, change, effect, companyName?, expiresAt } or { taskId, requestId, status: "complete" } or { error }.
    • requestedBy: the signed-in person's name. companyName is optional.
    • change is { kind: "takeOwnership" } or { kind: "role", personName, role, roleLabel }; effect is the same change as one sentence.
  • POST /v1/dev/me/people-confirm/{token} (empty body) -> { taskId, requestId, status: "complete" | "pending" } or { error }.
  • error is one of not_found (not yours and no such task read the same), changed, unavailable.
  • The old /review/<task>/task/people/confirm/<request> answers a 302 to ${WEB_APP_ORIGIN}/app/people-confirm/<token> for one release; the old /review/link/<code> answers a 302 to ${WEB_APP_ORIGIN}/app/account/slack/link/<code>. With no WEB_APP_ORIGIN both stay as they were.

Behaviour

  • One Slack account per person per workspace, enforced on the server (a place row written in the link's own transaction, so two requests at once cannot both link; unlink first to change). Another person's account is never taken (linked_to_other).
  • No silent link by email.
  • After any successful link the Slack user gets: "Your Slack account was just linked to in Rovara. Not you? " (the link goes to the app's Account page).
  • Audit rows company.slack_linked and company.slack_unlinked in the same transaction as the change.
  • Connect Slack in Connected sign-ins is not a dead end: when the Slack team is the company's connected workspace, finishing it also creates the company channel link (idempotent, audited, never overrides someone else's link; the finish answer carries slackLink). A contract test proves such a person is recognised in a Slack DM.
  • F4 (a used or expired code gets a fresh one), F7 (/rovara and the task notifier use the link-aware person resolver; ChatGPT-from-Slack is already refused in company mode), F2 (every refused browser return shows a fixed-reason page, no redirect, no detail). "Sign in with Slack" notices now point at Account.

Infra and IAM

  • No new IAM and no new DynamoDB grant: the Slack ingress still delegates the link notice to the broker.
  • New broker setting webAppOrigin (packed wo, read as WEB_APP_ORIGIN) packed from the existing CoreAttentionEmailHost: no new stack parameter, no new config key. scripts/settings-growth-baseline.json names it; the reason is the owner's 2026-12-05 decision to move the pages to the app. Empty stays empty and the broker keeps the API host's pages.

Checks

  • light-gate on the merged head: tsc, 5 typecheck shards, eslint, complexity (no baseline raised; two files lowered), port-guard, gitleaks, all 294 importer test files, inventory: pass.
  • Full tests/contract, tests/journeys and the company, inventory and settings unit suites: 1056 files pass.
  • Template pins moved only for the packed wo (Rule D helper withoutWebAppOrigin); the code-api version digest line for 1.33 is added.

🤖 Generated with Claude Code


Show it working
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

m2 and others added 7 commits December 5, 2026 14:22
…m moves to the app (Code API 1.31)

One place to link a Slack account: Account in the web app. The person confirms the code Slack sent them (GET and POST /v1/dev/me/slack-links/pending/{token}), lists and unlinks their own links (opaque linkId, never a Slack user id in an address), and a company owner or admin lists who linked and removes one person's links (GET /v1/dev/company/slack/people, DELETE .../{personId}). All web-app-only.

Rules enforced on the server: one Slack account per person per workspace (a place row written in the link's own transaction, so two requests at once cannot both link), another person's account is never taken over, no silent link by email (the preview answers match, different or unknown, never the address, unknown without the Slack email scope). Every successful link sends the Slack user a safety message with an unlink link to Account; link and unlink write audit rows (company.slack_linked, company.slack_unlinked) in the same transaction.

Connect Slack in Connected sign-ins is no longer a dead end: after the sign-in link succeeds, when the Slack team is the company's connected workspace the same account becomes the company channel link (idempotent, audited, reports linked_to_other instead of overriding).

F4: a code that is used or expired gets a fresh one at once (the notice claim lives as long as the code and a link ends it). F7: /rovara asks the link-aware person resolver; the task notifier names a plan owner by link too. F2: every refused browser-return sign-in shows a page with a fixed reason instead of a silent redirect. The "sign in with Slack" notices now point at Account.

The People confirmation moves to the app: GET and POST /v1/dev/me/people-confirm/{token}. The old pages answer a 302 to the app when WEB_APP_ORIGIN is set (derived from the attention-email host).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…t two route functions

The broker reads the web app's origin as WEB_APP_ORIGIN, packed from the existing CoreAttentionEmailHost (setting `wo`, https origin; empty stays empty) instead of a separate environment variable, so the broker's 4 KB environment is unchanged in shape. Template pins moved for exactly that (a Rule D helper takes it out), the route-table pins carry the eight new rows, the company inventory lists the new link-code index row, the person slot row and the six Slack link routes, and the complexity baseline drops for two files that got simpler.

Fixes: the Slack link store wrapper passes query and delete through (a redeem read the person's links); slack-person-link-routes and people-confirm-app-routes functions split under the complexity limit; the broker's Slack company wiring is built before the developer configuration reads it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…nce, growth baseline, F2 golden

The broker reads WEB_APP_ORIGIN where the environment is already read (the developer configuration and the Slack company wiring), so broker.ts adds no direct process.env read. The settings growth baseline names the one new broker setting (the web app origin, packed from the existing CoreAttentionEmailHost: no new stack parameter and no new config key). The legacy packed-environment list and the broker-environment fixture carry it. The browser-callback error test now pins the F2 page (fixed reason, no redirect, no detail) in place of the old silent redirect.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…(1.31 and 1.32 are taken)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…contract, grant the notifier's link read, erase counts

- People confirm: the page redirect goes to /app/people/confirm/<token> (the website's route); POST answers COMMITTED/PENDING and refusals are 404/409/503 errors, as the website reads them.
- IAM: the notifier's F7 read of ORG#<c>#CHANNEL_LINK#slack/* had no grant (swallowed AccessDenied); granted, with a key-family-to-grant test and template re-pins.
- Erase no longer counts the workspace place row as a link; unlink with a malformed address reads unlinked:false.
- Tests: open-redirect, cross-team/cross-company unlink, replay, expiry, one safety message, revoked member.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…d safety-message the old page, mask short ids

- Connected sign-ins' Slack finish: an identity of the install's own workspace names no team; it was linked to the
  company's workspace unchecked. Now linked only when the install's workspace (SLACK_TEAM_ID) IS the company's.
- The old /review/link page (served while WEB_APP_ORIGIN is unset, where every notice points) linked with no audit
  row and no safety message. Its confirmation now goes through the app's own confirmation; another company's or a
  disconnected workspace's code never falls through to the plain redeem.
- maskChannelUserId hides at least three characters (a 7-character id was shown whole).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	docs/architecture/company-inventory.md
#	packages/broker/src/aws/broker.ts
#	packages/code-api/src/version.ts
#	tests/contract/admin-health.test.ts
#	tests/contract/admin-read-contracts.test.ts
#	tests/contract/code-api-version.test.ts
#	tests/contract/core-engine-infrastructure.test.ts
#	tests/contract/developer-contracts.test.ts
#	tests/contract/developer-identity-server.test.ts
#	tests/contract/developer-share-contracts.test.ts
#	tests/contract/developer-signin-infrastructure.test.ts
#	tests/contract/developer-task-shapes.test.ts
#	tests/contract/legacy-templates.test.ts
#	tests/contract/named-templates.test.ts
#	tests/fixtures/signin-company-goldens/configuration.json
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.

2 participants