diff --git a/main.go b/main.go index cbcda6f..344830d 100644 --- a/main.go +++ b/main.go @@ -243,8 +243,7 @@ func (br *bridge) publish(n *notification) error { // ntfy authentication if br.cfg.ntfy.Password != "" && br.cfg.ntfy.User != "" { - auth := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", br.cfg.ntfy.User, br.cfg.ntfy.Password))) - req.Header.Set("Authorization", fmt.Sprintf("Basic %s", auth)) + req.SetBasicAuth(br.cfg.ntfy.User, br.cfg.ntfy.Password) } else if br.cfg.ntfy.AccessToken != "" { req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", br.cfg.ntfy.AccessToken)) } diff --git a/silence.go b/silence.go index 78d0951..b4cfc32 100644 --- a/silence.go +++ b/silence.go @@ -4,7 +4,6 @@ import ( "bytes" "encoding/base64" "encoding/json" - "fmt" "io" "net/http" "time" @@ -104,8 +103,7 @@ func (br *bridge) handleSilences(w http.ResponseWriter, r *http.Request) { // Basic auth if br.cfg.am.User != "" && br.cfg.am.Password != "" { - auth := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", br.cfg.am.User, br.cfg.am.Password))) - req.Header.Set("Authorization", fmt.Sprintf("Basic %s", auth)) + req.SetBasicAuth(br.cfg.am.User, br.cfg.am.Password) } req.Header.Add("Content-Type", "application/json")