Skip to content

feat(slack): add user authorization with admin commands and MongoDB persistence#917

Draft
sriaradhyula wants to merge 1 commit intomainfrom
prebuild/feat/slack-authz
Draft

feat(slack): add user authorization with admin commands and MongoDB persistence#917
sriaradhyula wants to merge 1 commit intomainfrom
prebuild/feat/slack-authz

Conversation

@sriaradhyula
Copy link
Copy Markdown
Member

Summary

  • Introduce a UserAuthorizer class that gates access to the CAIPE Slack Bot with two modes: open (default, everyone allowed) and restricted (explicit allow-list required)
  • Support static allow/deny lists via environment variables (SLACK_INTEGRATION_AUTHORIZED_USERS, SLACK_INTEGRATION_DENIED_USERS), channel-level authorized users via config, and dynamic grants persisted in MongoDB
  • Add admin commands via @mention: @caipe authorize @user, @caipe revoke @user, @caipe authz list
  • Wire authorization checks into handle_mention, handle_qanda_message, and handle_dm_message handlers with appropriate ephemeral/direct denial messages
  • Add authorized_users field to ChannelConfig for per-channel access control

Test plan

  • Set SLACK_INTEGRATION_AUTHZ_MODE=restricted and verify unauthorized users receive denial messages
  • Set SLACK_INTEGRATION_AUTHZ_MODE=open and verify all users can interact
  • Add a user to SLACK_INTEGRATION_DENIED_USERS and verify they are blocked even in open mode
  • Test admin commands: @caipe authorize @user, @caipe revoke @user, @caipe authz list
  • Verify dynamic grants persist across restarts when MONGODB_URI is set
  • Test channel-level authorized_users in bot config restricts access per-channel

Made with Cursor

…ersistence

Introduce a UserAuthorizer that gates access to the CAIPE Slack Bot with
two modes: open (default) and restricted. The deny list is always checked
first, followed by the admin list, then mode-specific resolution.

- Add authorization.py with open/restricted mode, static allow/deny lists,
  channel-level authorized_users, and dynamic grants persisted in MongoDB
- Wire authz checks into handle_mention, handle_qanda_message, and
  handle_dm_message handlers
- Add admin commands via @mention: authorize, revoke, and authz list
- Add authorized_users field to ChannelConfig for per-channel access control

Signed-off-by: Sri Aradhyula <sraradhy@cisco.com>
Made-with: Cursor
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 8, 2026

✅ No proprietary content detected. This PR is clear for review!

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 8, 2026

📊 Test Coverage Report

Main Tests Coverage

Metric Coverage Details
Lines 41.4% 7333/17702 lines
Branches 0.0% 0/0 branches

📁 Coverage Artifacts

  • Main tests: coverage-reports-main artifact
  • RAG tests: coverage-reports-rag artifact (not available)
  • Download artifacts to view detailed HTML coverage reports

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 8, 2026

🐳 Prebuild Docker Image Published

Repository: ghcr.io/cnoe-io/prebuild/caipe-slack-bot
Tag: feat-slack-authz-2

Usage

docker pull ghcr.io/cnoe-io/prebuild/caipe-slack-bot:feat-slack-authz-2

Note: This prebuild image will be automatically cleaned up when the PR is closed or merged.

@kevkantes
Copy link
Copy Markdown
Collaborator

I think this is fine, we personally probably would just set this to open though. Is there a specific use case that's prompted this change?

@kevkantes
Copy link
Copy Markdown
Collaborator

Also our config is handled entirely through yaml, we shouldn't mix and match with slack commands and config, that has been a somewhat confusing experience for our RAG ingestion. Maybe for now we do everything through config yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Development

Successfully merging this pull request may close these issues.

2 participants