Repository navigation
Description
Context
Raised while deploying the bot into stacklok/infra staging2 (infra#5583, infra#5585) and in a follow-up team discussion (Daniel Kantor, Juan Antonio Osorio) about access control. The bot's current SLACK_ALLOWED_USER_IDS has real problems:
- It's a hand-maintained list of opaque Slack member IDs (
U0123ABCDEF) - error-prone to compile and to keep current. Nothing removes someone automatically when they leave. - It doesn't distinguish real workspace members from guests. A Slack workspace can contain single/multi-channel guests, or (via Slack Connect) members of an entirely different company -
SLACK_ALLOWED_USER_IDShas no concept of this. - Not every Slack account maps to an Okta account at all - guests are added straight into Slack and never go through an identity-provider onboarding pipeline, so "verify against Okta" is structurally impossible for that population, not just hard.
What's realistically in scope for this repo
Two things, both generic and Slack-only (no Okta, no directory service, nothing org-specific):
- Resolve the sender's verified email via
users.info(needs theusers:read.emailscope) instead of only having their opaque ID. Slack genuinely verifies this email at signup, at any email change, and (for guests) at invite acceptance - so it's a real, human-recognizable identity, not just another opaque token. - Reject guests and deactivated accounts using the same
users.infocall'sis_restricted/is_ultra_restricted/deletedfields.
Replace SLACK_ALLOWED_USER_IDS with an email-based allowlist using these two signals as the new default.
What's explicitly NOT in scope here
Anything involving Okta, a live roster/group check, or an org's internal directory service. That's real, org-specific backend work (Okta API credentials, caching, a directory-service integration) that doesn't belong in this reference bot. It should be a separate, pluggable adapter, not code merged into this repo.
Proposed shape: a small AccessResolver seam
interface AccessResolver {
resolve(ctx: SlackMessageContext): Promise<AccessDecision>;
}
interface SlackMessageContext {
slackUserId: string;
channelId?: string; // absent for DMs
}
type AccessDecision =
| { allowed: false }
| { allowed: true; principal: string };The interface only speaks in Slack-native terms (a user ID, a channel ID) - it never mentions email, Okta, or any directory concept. That's what keeps the bot generic.
- Default adapter (this repo):
EmailAllowlistResolver- does theusers.infocall, checks the configured email list, rejects guests/deactivated accounts. Fully generic, ships as the reference implementation, replacesSLACK_ALLOWED_USER_IDS. - Org-specific adapters (NOT this repo): e.g. an Okta-roster-backed resolver, or a directory-service/channel-group-backed resolver for group-scoped (not just per-user) access. Injected via config at the consuming deployment's level, implementing the same tiny interface. Stacklok's own staging deployment is the first candidate consumer of a custom adapter like this, once that backend work is prioritized - tracked separately, not blocked on this issue.
This also naturally opens the door to channel-scoped decisions later (an adapter could resolve a channel ID to a group principal and inherited budget) without changing the interface at all - channelId is already part of the context.
Verification
- Existing behavior (env-var-based allowlist) should keep working during migration, or be cleanly replaced with a documented
SLACK_ALLOWED_USER_IDS→SLACK_ALLOWED_EMAILSmigration note in the README. - Test the guest-rejection path and the email-match path independently (fake
users.inforesponses, no real Slack workspace needed - matches this package's existing offline-test pattern withmecated --mock).
Related: infra#5583, infra#5585 (the staging2 deployment that surfaced this), #1085 (hardened image), #1191 (health-check endpoint) - same "tracked follow-up, not blocking anything currently deployed" shape as those two.
Activity
feat(slack-bot): pluggable AccessResolver, default to an email allowlist
fix(slack-bot): close Slack Connect gap, decouple resolver wiring fro…