allow empty username in case of access tokens in Basic Auth
This commit is contained in:
parent
9aa539bb4f
commit
2ce561304a
1 changed files with 3 additions and 1 deletions
4
main.go
4
main.go
|
@ -59,7 +59,9 @@ func WebhookHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
req.Header.Set("Tags", strings.Join(maps.Values(alert.Labels), ","))
|
req.Header.Set("Tags", strings.Join(maps.Values(alert.Labels), ","))
|
||||||
|
|
||||||
username, password := os.Getenv("NTFY_USER"), os.Getenv("NTFY_PASS")
|
username, password := os.Getenv("NTFY_USER"), os.Getenv("NTFY_PASS")
|
||||||
if username != "" && password != "" {
|
// allow empty `username` (access tokens in Basic Auth leave username empty)
|
||||||
|
// <https://docs.ntfy.sh/publish/#access-tokens>
|
||||||
|
if password != "" {
|
||||||
req.SetBasicAuth(username, password)
|
req.SetBasicAuth(username, password)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue