Skip to content

Commit

Permalink
feat(endpoint): drop id specific check for secret keys in all endpoints
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jsteenb2 committed Dec 17, 2019
1 parent 2581825 commit 9183bb4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
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 == "" {
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

0 comments on commit 9183bb4

Please sign in to comment.