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

feat(endpoints): drop id prefix req endpoint secret key #16242

Merged
merged 1 commit into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
### Features

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

1. [16225](https://github.com/influxdata/influxdb/pull/16225): Ensures env vars are applied consistently across cmd, and fixes issue where INFLUX\_ env var prefix was not set globally.

1. [16235](https://github.com/influxdata/influxdb/pull/16235): Removed default frontend sorting when flux queries specify sorting
1. [16238](https://github.com/influxdata/influxdb/pull/16238): Store canceled task runs in the correct bucket
1. [16237](https://github.com/influxdata/influxdb/pull/16237): Updated Sortby functionality for table frontend sorts to sort numbers correctly
Expand Down
28 changes: 2 additions & 26 deletions notification/endpoint/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ func TestValidEndpoint(t *testing.T) {
},
},
{
name: "empty slack url and token",
name: "empty slack url",
src: &endpoint.Slack{
Base: goodBase,
},
err: &influxdb.Error{
Code: influxdb.EInvalid,
Msg: "slack endpoint URL and token are empty",
Msg: "slack endpoint URL must be provided",
},
},
{
Expand All @@ -99,30 +99,6 @@ func TestValidEndpoint(t *testing.T) {
},
err: nil,
},
{
name: "invalid slack token",
src: &endpoint.Slack{
Base: goodBase,
URL: "localhost",
Token: influxdb.SecretField{Key: "bad-key"},
},
err: &influxdb.Error{
Code: influxdb.EInvalid,
Msg: "slack endpoint token is invalid",
},
},
{
name: "invalid routine key",
src: &endpoint.PagerDuty{
Base: goodBase,
ClientURL: "localhost",
RoutingKey: influxdb.SecretField{Key: "bad-key"},
},
err: &influxdb.Error{
Code: influxdb.EInvalid,
Msg: "pagerduty routing key is invalid",
},
},
{
name: "empty http http method",
src: &endpoint.HTTP{
Expand Down
6 changes: 2 additions & 4 deletions notification/endpoint/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion notification/endpoint/pagerduty.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 2 additions & 9 deletions notification/endpoint/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "" {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

token is not required for a url, if URL is "" it shoudl be an eror for slack, token shoudn't matter

return &influxdb.Error{
Code: influxdb.EInvalid,
Msg: "slack endpoint URL and token are empty",
Msg: "slack endpoint URL must be provided",
}
}
if s.URL != "" {
Expand All @@ -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
}

Expand Down