Skip to content

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

Closed

Description

@kantord

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_IDS has 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):

  1. Resolve the sender's verified email via users.info (needs the users:read.email scope) 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.
  2. Reject guests and deactivated accounts using the same users.info call's is_restricted / is_ultra_restricted / deleted fields.

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 the users.info call, checks the configured email list, rejects guests/deactivated accounts. Fully generic, ships as the reference implementation, replaces SLACK_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_EMAILS migration note in the README.
  • Test the guest-rejection path and the email-match path independently (fake users.info responses, no real Slack workspace needed - matches this package's existing offline-test pattern with mecated --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

  1. added
    enhancement
    on Sep 8, 2026
  2. self-assigned this
    on Sep 9, 2026
  3. added 2 commits that reference this issue on Sep 9, 2026
    82c38f0
    aa9cb68
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions