From 85edc9894adedb2ab2b595a687c99d4d183e9c1e Mon Sep 17 00:00:00 2001 From: Johnny Steenbergen Date: Tue, 17 Dec 2019 11:23:30 -0800 Subject: [PATCH] feat(endpoint): drop id specific check for secret keys in all endpoints the original design made the secrets unable to be reused, a bit to opinionated to be useful eleswhere. This relaxes that requirement so that secrets can be referenced here. --- CHANGELOG.md | 3 ++- notification/endpoint/http.go | 6 ++---- notification/endpoint/pagerduty.go | 2 +- notification/endpoint/slack.go | 11 ++--------- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86f033b4916..b6e63f7d7b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ ### Features -1. [16234](https://github.com/influxdata/influxdb/pull/16234): add support for notification endpoints to influx templates/pkgs. +1. [16234](https://github.com/influxdata/influxdb/pull/16234): add support for notification endpoints to influx templates/pkgs. +2. [16242](https://github.com/influxdata/influxdb/pull/16242): drop id prefix for secret key requirement for notification endpoints ### Bug Fixes diff --git a/notification/endpoint/http.go b/notification/endpoint/http.go index a49e268de96..bc07315bb13 100644 --- a/notification/endpoint/http.go +++ b/notification/endpoint/http.go @@ -103,15 +103,13 @@ func (s HTTP) Valid() error { Msg: "invalid http auth method", } } - if s.AuthMethod == "basic" && - (s.Username.Key != s.ID.String()+httpUsernameSuffix || - s.Password.Key != s.ID.String()+httpPasswordSuffix) { + if s.AuthMethod == "basic" && (s.Username.Key == "" || s.Password.Key == "") { return &influxdb.Error{ Code: influxdb.EInvalid, Msg: "invalid http username/password for basic auth", } } - if s.AuthMethod == "bearer" && s.Token.Key != s.ID.String()+httpTokenSuffix { + if s.AuthMethod == "bearer" && s.Token.Key == "" { return &influxdb.Error{ Code: influxdb.EInvalid, Msg: "invalid http token for bearer auth", diff --git a/notification/endpoint/pagerduty.go b/notification/endpoint/pagerduty.go index af9faf0d8a7..4233c372ee5 100644 --- a/notification/endpoint/pagerduty.go +++ b/notification/endpoint/pagerduty.go @@ -40,7 +40,7 @@ func (s PagerDuty) Valid() error { if err := s.Base.valid(); err != nil { return err } - if s.RoutingKey.Key != s.ID.String()+routingKeySuffix { + if s.RoutingKey.Key == "" { return &influxdb.Error{ Code: influxdb.EInvalid, Msg: "pagerduty routing key is invalid", diff --git a/notification/endpoint/slack.go b/notification/endpoint/slack.go index f897b25e1d0..f18faf12687 100644 --- a/notification/endpoint/slack.go +++ b/notification/endpoint/slack.go @@ -45,10 +45,10 @@ func (s Slack) Valid() error { if err := s.Base.valid(); err != nil { return err } - if s.URL == "" && s.Token.Key == "" { + if s.URL == "" { return &influxdb.Error{ Code: influxdb.EInvalid, - Msg: "slack endpoint URL and token are empty", + Msg: "slack endpoint URL must be provided", } } if s.URL != "" { @@ -59,13 +59,6 @@ func (s Slack) Valid() error { } } } - // TODO(desa): this requirement seems odd - if s.Token.Key != "" && s.Token.Key != s.ID.String()+slackTokenSuffix { - return &influxdb.Error{ - Code: influxdb.EInvalid, - Msg: "slack endpoint token is invalid", - } - } return nil }