1
0
Fork 0

allow empty username in case of access tokens in Basic Auth

This commit is contained in:
Daniel Lambert 2024-03-23 21:15:31 -05:00
parent 9aa539bb4f
commit 2ce561304a

View file

@ -59,7 +59,9 @@ func WebhookHandler(w http.ResponseWriter, r *http.Request) {
req.Header.Set("Tags", strings.Join(maps.Values(alert.Labels), ","))
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)
}