You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Slack app support
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 #2513
[1]: https://api.slack.com/legacy/custom-integrations/messaging/webhooks
Signed-off-by: Pedro Araujo <[email protected]>
* Support transition from workaround to new config
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]: #2513
* Allow override from receiver-level webhook url
Signed-off-by: Pedro Araujo <[email protected]>
* Fix linter errors
Fixed by running `make common-lint-fix`
Signed-off-by: Pedro Araujo <[email protected]>
---------
Signed-off-by: Pedro Araujo <[email protected]>
Co-authored-by: Ben Kochie <[email protected]>
t.Fatalf("Expected an error parsing %s: %s", "testdata/conf.slack-both-url-and-token.yml", err)
1230
+
}
1231
+
iferr.Error() !="at most one of slack_app_token/slack_app_token_file & slack_api_url/slack_api_url_file must be configured" {
1232
+
t.Errorf("Expected: %s\nGot: %s", "at most one of slack_app_token/slack_app_token_file & slack_api_url/slack_api_url_file must be configured", err.Error())
0 commit comments