From 85eb9160d81aef0ed4649f709d27da6e9393815c Mon Sep 17 00:00:00 2001 From: Hunter Kehoe Date: Sun, 9 Oct 2022 08:34:23 -0600 Subject: [PATCH 1/2] `ntfy pub`: use `default-user` and `default-password` from `client.yml` fixes #431 --- client/client.yml | 6 +++++- cmd/publish.go | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/client/client.yml b/client/client.yml index 3cd5736c..d3ba2722 100644 --- a/client/client.yml +++ b/client/client.yml @@ -5,10 +5,14 @@ # # default-host: https://ntfy.sh -# Defaults below will be used when a topic does not have its own settings +# Default username and password will be used with "ntfy publish" if no credentials are provided on command line +# Default username and password will be used with "ntfy subscribe" if no credentials are provided in subscription below +# For an empty password, use empty double-quotes ("") # # default-user: # default-password: + +# Default command will execute after "ntfy subscribe" receives a message if no command is provided in subscription below # default-command: # Subscriptions to topics and their actions. This option is primarily used by the systemd service, diff --git a/cmd/publish.go b/cmd/publish.go index 0b995258..efa875bf 100644 --- a/cmd/publish.go +++ b/cmd/publish.go @@ -160,6 +160,8 @@ func execPublish(c *cli.Context) error { fmt.Fprintf(c.App.ErrWriter, "\r%s\r", strings.Repeat(" ", 20)) } options = append(options, client.WithBasicAuth(user, pass)) + } else if conf.DefaultUser != "" && conf.DefaultPassword != nil { + options = append(options, client.WithBasicAuth(conf.DefaultUser, *conf.DefaultPassword)) } if pid > 0 { newMessage, err := waitForProcess(pid) From 5d9702b10bd4cea5cd71e5aa11c3ebc5ef396177 Mon Sep 17 00:00:00 2001 From: Hunter Kehoe Date: Sun, 9 Oct 2022 08:37:58 -0600 Subject: [PATCH 2/2] release notes --- docs/releases.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/releases.md b/docs/releases.md index c03d63ff..314f3c0b 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -14,6 +14,7 @@ and the [ntfy Android app](https://github.com/binwiederhier/ntfy-android/release * Bump Go version to Go 18.x ([#422](https://github.com/binwiederhier/ntfy/issues/422)) * Web: Strip trailing slash when subscribing ([#428](https://github.com/binwiederhier/ntfy/issues/428), thanks to [@raining1123](https://github.com/raining1123) for reporting, and [@wunter8](https://github.com/wunter8) for fixing) * Allow empty passwords in `client.yml` ([#374](https://github.com/binwiederhier/ntfy/issues/374), thanks to [@cyqsimon](https://github.com/cyqsimon) for reporting, and [@wunter8](https://github.com/wunter8) for fixing) +* `ntfy pub` will now use default username and password from `client.yml` ([#431](https://github.com/binwiederhier/ntfy/issues/431), thanks to [@wunter8](https://github.com/wunter8) for fixing) **Documentation:**