1
0
Fork 0

Merge pull request #6 from danjl1100/allow-empty-user

allow empty username in case of access tokens in Basic Auth
This commit is contained in:
Pablo Ovelleiro Corral 2024-03-24 21:31:45 +01:00 committed by GitHub
commit fca24b84f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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)
}