Simplify outgoing Basic Authentication
This commit is contained in:
parent
d7fdd85b72
commit
82a22c8959
2 changed files with 2 additions and 5 deletions
3
main.go
3
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))
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue