fix: allow authToken for webhook to support Splunk

This commit is contained in:
Harshavardhana 2021-07-09 10:08:04 -07:00 committed by Minio Trusted
parent cf8ff4c1bc
commit a28fee5bc3
1 changed files with 10 additions and 1 deletions

View File

@ -29,6 +29,7 @@ import (
"net/url"
"os"
"path/filepath"
"strings"
"time"
"github.com/minio/minio/pkg/certs"
@ -162,7 +163,15 @@ func (target *WebhookTarget) send(eventData event.Event) error {
return err
}
if target.args.AuthToken != "" {
// Verify if the authToken already contains
// <Key> <Token> like format, if this is
// already present we can blindly use the
// authToken as is instead of adding 'Bearer'
tokens := strings.Fields(target.args.AuthToken)
switch len(tokens) {
case 2:
req.Header.Set("Authorization", target.args.AuthToken)
case 1:
req.Header.Set("Authorization", "Bearer "+target.args.AuthToken)
}