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:
commit
fca24b84f2
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), ","))
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue