Repository navigation
feat(slack-bot): pluggable AccessResolver, default to an email allowlist - #1294
Merged
Merged
Conversation
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
marked this pull request as ready for review
September 9, 2026 16:35
rdimitrov
approved these changes
Sep 9, 2026
samuv
requested changes
Sep 10, 2026
samuv
left a comment
Contributor
There was a problem hiding this comment.
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
requested changes
Sep 10, 2026
samuv
left a comment
Contributor
There was a problem hiding this comment.
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
approved these changes
Sep 10, 2026
samuv
left a comment
Contributor
There was a problem hiding this comment.
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.
This was referenced Sep 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SLACK_ALLOWED_USER_IDS(a hand-maintained list of opaque Slack member IDs that nothing removes someone from automatically) with a pluggableAccessResolverseam (src/access.ts) and its default, generic implementation,EmailAllowlistResolver.EmailAllowlistResolverresolves the sender's verified email viausers.infoand 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 optionalSLACK_ALLOWED_EMAILS(exact match) and/orSLACK_ALLOWED_EMAIL_DOMAINS(domain match, for "everyone at this company" without a hand-maintained list) gate the rest.AccessResolverinterface, injected at the consuming deployment's level — not this reference bot's job.users:read+users:read.emailbot scopes toslack-app-manifest.json.SLACK_ALLOWED_USER_IDSis removed, no dual-support).Fixes #1241.
Test plan
npx vitest run— newtest/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) + updatedtest/agentSessions.test.tsnpx tsc --noEmitnpx biome check .🤖 Generated with Claude Code