Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict bot usage to specific channels or users #94

Closed

Conversation

PeterDaveHello
Copy link

@PeterDaveHello PeterDaveHello commented Jul 5, 2024

Related to #32

Add access control feature to restrict bot usage to specific channels or users.

  • Environment Variables: Add ALLOWED_CHANNELS and ALLOWED_USERS environment variables in main.py and main_prod.py to specify allowed channels and users.
  • Middleware: Update middleware in main.py and main_prod.py to check if the bot is allowed in the channel or by the user.
  • Access Control Function: Add is_bot_allowed function in app/bolt_listeners.py to check if the bot is allowed to respond based on the specified channels and users.
  • Event Handlers: Update respond_to_app_mention and respond_to_new_message in app/bolt_listeners.py to use is_bot_allowed function.
  • Documentation: Update README.md to include instructions on how to configure the ALLOWED_CHANNELS and ALLOWED_USERS environment variables.

For more details, open the Copilot Workspace session.

@seratch
Copy link
Owner

seratch commented Sep 5, 2024

Thank you for sending this PR. I apologize for my slow response. Access control could indeed be useful for enterprise use cases, but there are many ways people might want to configure it (e.g., managing the list in a database, workspace level for an enterprise grid org, etc.). Thus, this environment variable approach may not meet everyone's needs. Please consider forking this project or referring to this repo as a Git submodule and implementing your own global middleware and main.py.

@seratch seratch closed this Sep 5, 2024
@seratch
Copy link
Owner

seratch commented Sep 5, 2024

In #32, I said "Happy with having some env variables to customize main.py for the use case described here." but while checking your code, I changed my mind. I'm sorry about that.

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.

2 participants