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

Slack app support #4211

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

pharaujo
Copy link

While it's possible to configure Slack app bot tokens using a combination of http_configs authorization credentials and setting the Slack API URL to the a specific endpoint, doing so at a global level leaks the token to any other notification receiver configured, as http_configs are not specific to notifiers. Slack has also restricted webhook URLs to only be able to post to a single channel (with the legacy webhooks being marked as deprecated and not recommended), which reduces their usefulness when set at the global level.

This PR adds a way of easily setting Slack App bot tokens at the global level, as well as overriding at the individual receiver level, while keeping compatibility with existing configurations.

The decision to have a separate config field for the URL was to be able to provide a default API URL for Slack apps as well as differentiate when a webhook url is provided. Ideally we'd change the slack_api_url to be slack_webhook_url so as to avoid confusion, but that would be an unnecessary breaking change.

More context in issue #2513

@pharaujo pharaujo force-pushed the slack_token_auth branch 2 times, most recently from c9c52d3 to c32a184 Compare January 17, 2025 12:38
While it's possible to configure Slack app bot tokens using a
combination of http_configs authorization credentials and setting the
Slack API URL to the a specific endpoint, doing so at a global level
leaks the token to any other notification receiver configured, as
http_configs are not specific to notifiers. Slack has also restricted
webhook URLs to only be able to post to a single channel (with the
legacy webhooks being [marked as deprecated and not recommended][1]),
which reduces their usefulness when set at the global level.

This PR adds a way of easily setting Slack App bot tokens at the global
level, as well as overriding at the individual receiver level, while
keeping compatibility with existing configurations.

The decision to have a separate config field for the URL was to be able
to provide a default API URL for Slack apps as well as differentiate
when a webhook url is provided. Ideally we'd change the `slack_api_url`
to be `slack_webhook_url` so as to avoid confusion, but that would be an
unnecessary breaking change.

More context in issue prometheus#2513

[1]: https://api.slack.com/legacy/custom-integrations/messaging/webhooks

Signed-off-by: Pedro Araujo <[email protected]>
@pharaujo pharaujo marked this pull request as ready for review January 20, 2025 17:27
@grobinson-grafana
Copy link
Contributor

So we do also need BlockKit support, and I think this feature, along with BlockKit, would be perfect for a Slack V2 integration, just like we did for Microsoft Teams.

@pharaujo
Copy link
Author

pharaujo commented Feb 3, 2025

So we do also need BlockKit support, and I think this feature, along with BlockKit, would be perfect for a Slack V2 integration, just like we did for Microsoft Teams.

I'm a bit confused. Is this feedback for me, or for other reviewers? Are you saying I should implement this under a new slack integration, or close this PR since someone else is implementing it together with Block Kit?

To be clear, I'm able to change the PR to kickstart the new slack integration and plug internals into the current integration, but I don't want to extend the scope of this PR to add such a large piece of work such as Block Kit.

What's the recommendation here?

The [Slack app support issue][1] suggested setting the slack API URL to
the `chat.PostMessage` endpoint instead of a webhook URL, and so people
migrating from this workaround to the the new configuration might
encounter a situation where they want to set the `slack_app_token` at
the global level while still retaining the `slack_api_url` while
dynamically configured receivers (such as those set by prometheus
operator) are migrated.

Signed-off-by: Pedro Araujo <[email protected]>

[1]: prometheus#2513
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