From 2ce561304ae72dae59cbceaa518fe92cb2c8cc1c Mon Sep 17 00:00:00 2001 From: Daniel Lambert Date: Sat, 23 Mar 2024 21:15:31 -0500 Subject: [PATCH] allow empty username in case of access tokens in Basic Auth --- main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 82b7534..688b3f8 100644 --- a/main.go +++ b/main.go @@ -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) + // + if password != "" { req.SetBasicAuth(username, password) }