From 9370acbcfeaacf6b686ac455f4636c0f61aba819 Mon Sep 17 00:00:00 2001 From: binwiederhier Date: Mon, 6 Mar 2023 23:12:46 -0500 Subject: [PATCH] Cosmetic changes --- cmd/publish.go | 38 ++++++++++++++++++-------------------- docs/releases.md | 2 +- server/server.go | 2 +- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/cmd/publish.go b/cmd/publish.go index b70ef6f4..0179f9fa 100644 --- a/cmd/publish.go +++ b/cmd/publish.go @@ -154,28 +154,26 @@ func execPublish(c *cli.Context) error { } if token != "" { options = append(options, client.WithBearerAuth(token)) - } else { - if user != "" { - var pass string - parts := strings.SplitN(user, ":", 2) - if len(parts) == 2 { - user = parts[0] - pass = parts[1] - } else { - fmt.Fprint(c.App.ErrWriter, "Enter Password: ") - p, err := util.ReadPassword(c.App.Reader) - if err != nil { - return err - } - pass = string(p) - fmt.Fprintf(c.App.ErrWriter, "\r%s\r", strings.Repeat(" ", 20)) + } else if user != "" { + var pass string + parts := strings.SplitN(user, ":", 2) + if len(parts) == 2 { + user = parts[0] + pass = parts[1] + } else { + fmt.Fprint(c.App.ErrWriter, "Enter Password: ") + p, err := util.ReadPassword(c.App.Reader) + if err != nil { + return err } - options = append(options, client.WithBasicAuth(user, pass)) - } else if conf.DefaultToken != "" { - options = append(options, client.WithBearerAuth(conf.DefaultToken)) - } else if conf.DefaultUser != "" && conf.DefaultPassword != nil { - options = append(options, client.WithBasicAuth(conf.DefaultUser, *conf.DefaultPassword)) + pass = string(p) + fmt.Fprintf(c.App.ErrWriter, "\r%s\r", strings.Repeat(" ", 20)) } + options = append(options, client.WithBasicAuth(user, pass)) + } else if conf.DefaultToken != "" { + options = append(options, client.WithBearerAuth(conf.DefaultToken)) + } else if conf.DefaultUser != "" && conf.DefaultPassword != nil { + options = append(options, client.WithBasicAuth(conf.DefaultUser, *conf.DefaultPassword)) } if pid > 0 { newMessage, err := waitForProcess(pid) diff --git a/docs/releases.md b/docs/releases.md index e1160683..6e9a0caa 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -2,7 +2,7 @@ Binaries for all releases can be found on the GitHub releases pages for the [ntfy server](https://github.com/binwiederhier/ntfy/releases) and the [ntfy Android app](https://github.com/binwiederhier/ntfy-android/releases). -## ntfy server v2.1.3 (UNRELEASED) +## ntfy server v2.2.0 (UNRELEASED) **Features:** diff --git a/server/server.go b/server/server.go index e1d2bc28..32da4513 100644 --- a/server/server.go +++ b/server/server.go @@ -1622,7 +1622,7 @@ func (s *Server) autorizeTopic(next handleFunc, perm user.Permission) handleFunc // maybeAuthenticate reads the "Authorization" header and will try to authenticate the user // if it is set. // -// - If auth-db is not configured, immediately return an IP-based visitor +// - If auth-file is not configured, immediately return an IP-based visitor // - If the header is not set or not supported (anything non-Basic and non-Bearer), // an IP-based visitor is returned // - If the header is set, authenticate will be called to check the username/password (Basic auth),