Skip to content

feat(slack-bot): pluggable AccessResolver, default to an email allowlist - #1294

Merged
kantord merged 3 commits into
mainfrom
issue-1241
Sep 10, 2026
Merged

kantord merged 3 commits into
mainfrom
issue-1241

Conversation

@kantord

@kantord kantord commented Sep 9, 2026

Copy link
Copy Markdown
Member

Summary

  • Replaces SLACK_ALLOWED_USER_IDS (a hand-maintained list of opaque Slack member IDs that nothing removes someone from automatically) with a pluggable AccessResolver seam (src/access.ts) and its default, generic implementation, EmailAllowlistResolver.
  • EmailAllowlistResolver resolves the sender's verified email via users.info and always rejects a deactivated account, a workspace guest (is_restricted/is_ultra_restricted), a Slack Connect member of a different company (is_stranger), or an explicitly unconfirmed email (is_email_confirmed === false) — identity-integrity checks, not configurable policy. Once identity is verified, the optional SLACK_ALLOWED_EMAILS (exact match) and/or SLACK_ALLOWED_EMAIL_DOMAINS (domain match, for "everyone at this company" without a hand-maintained list) gate the rest.
  • An org-specific identity backend (Okta-roster-backed, directory-service/channel-group-backed) is a separate adapter implementing the same AccessResolver interface, injected at the consuming deployment's level — not this reference bot's job.
  • Adds users:read + users:read.email bot scopes to slack-app-manifest.json.
  • README/DESIGN.md updated with the new config surface and a migration note (breaking: SLACK_ALLOWED_USER_IDS is removed, no dual-support).

Fixes #1241.

Test plan

  • npx vitest run — new test/access.test.ts (15 cases: guest/deactivated/stranger/unconfirmed-email rejection, exact-email match, domain match, fail-closed on API error/missing scope/missing user) + updated test/agentSessions.test.ts
  • npx tsc --noEmit
  • npx biome check .
  • Live smoke test against a real Slack workspace (not done here — reference bot, offline-only per this package's existing test pattern)

🤖 Generated with Claude Code

Replace SLACK_ALLOWED_USER_IDS (a hand-maintained list of opaque Slack
member IDs that nothing removed someone from automatically) with a
generic AccessResolver seam and its default EmailAllowlistResolver
implementation.

EmailAllowlistResolver resolves the sender's verified email via
users.info and always rejects a deactivated account, a workspace
guest (is_restricted/is_ultra_restricted), a Slack Connect member of
a different company (is_stranger), or an explicitly unconfirmed
email (is_email_confirmed === false) -- identity-integrity checks,
not configurable policy. Once identity is verified, the optional
SLACK_ALLOWED_EMAILS (exact match) and/or SLACK_ALLOWED_EMAIL_DOMAINS
(domain match, for "everyone at this company" without a hand-
maintained list) gate the rest.

An org-specific identity backend (Okta-roster-backed, directory-
service/channel-group-backed) is a separate adapter implementing the
same AccessResolver interface, injected at the consuming deployment's
level -- not this reference bot's job.

Fixes #1241.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@kantord
kantord marked this pull request as ready for review September 9, 2026 16:35

@samuv samuv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pulling this seam together. I found one security gap in Slack Connect classification and two integration issues with the resolver contract. I left concrete suggestions inline.

…m BotConfig

Addresses samuv's review on #1294:

- Security gap: is_stranger is false for an external Slack Connect
  member who shares a channel with us, not just for a true stranger.
  Slack's API has no single "is external" field for this (confirmed
  against the users.info docs) -- the documented way to tell is
  comparing team_id. EmailAllowlistResolver now fetches its own
  installed workspace's team id once via auth.test (cached) and
  rejects any user whose team_id doesn't match, is_stranger
  notwithstanding.

- The "no allowlist configured" startup warning read BotConfig's
  email-allowlist fields directly inside registerAgentSessions,
  coupling it to the default EmailAllowlistResolver and misleading
  operators of a deployment using an injected, non-email-based
  resolver. Moved to index.ts, next to where the default resolver is
  actually constructed; the denial message is now backend-neutral.

- The DM branch passed the DM's own channelId into the resolver
  context. The AccessResolver contract (#1241) defines channelId as
  absent for DMs so a channel-aware resolver can tell a user-scoped
  DM decision apart from channel/group policy. Fixed, with a test
  asserting the resolver context.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

@samuv samuv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fixes. The three original findings are addressed. I found one follow-up availability issue in the new team lookup cache.

Addresses samuv's follow-up review on #1294. auth.test needs no extra
scope, so its failure is far more likely to be a transient network
blip than a permanent misconfiguration -- unlike a missing
users:read.email scope, which won't fix itself. Caching that
failure as a permanently-resolved undefined promise meant one bad
moment at startup denied every user for the rest of the process's
life, until a restart.

EmailAllowlistResolver now clears its cached team-id promise back to
undefined on auth.test failure or a response with no team_id, so the
next resolve() call retries -- the CURRENT call still fails closed.
A success is still cached for the resolver's lifetime, since the
installed workspace's team id never changes mid-process.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

@samuv samuv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the follow-up. The retry now fails closed for the current request, clears only unsuccessful lookups, and preserves successful caching. The regression test covers recovery after a transient failure. All of my review findings are addressed.

@kantord
kantord merged commit 6eae391 into main Sep 10, 2026
32 checks passed
@kantord
kantord deleted the issue-1241 branch September 10, 2026 13:35
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.

Slack bot: pluggable AccessResolver, default to an email allowlist instead of Slack IDs

3 participants