From e56eb0c17864d1bd4e9b0db44a320561a48440f1 Mon Sep 17 00:00:00 2001 From: Philipp Heckel Date: Tue, 1 Feb 2022 12:23:11 -0500 Subject: [PATCH] Allow 'ntfy access --reset' --- auth/auth_sqlite.go | 4 +++- server/server_firebase_test.go | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/auth/auth_sqlite.go b/auth/auth_sqlite.go index 71cd86ed..4b7eb38c 100644 --- a/auth/auth_sqlite.go +++ b/auth/auth_sqlite.go @@ -332,7 +332,9 @@ func (a *SQLiteAuth) AllowAccess(username string, topicPattern string, read bool // ResetAccess removes an access control list entry for a specific username/topic, or (if topic is // empty) for an entire user. The parameter topicPattern may include wildcards (*). func (a *SQLiteAuth) ResetAccess(username string, topicPattern string) error { - if (!AllowedUsername(username) && username != Everyone) || (!AllowedTopicPattern(topicPattern) && topicPattern != "") { + if !AllowedUsername(username) && username != Everyone && username != "" { + return ErrInvalidArgument + } else if !AllowedTopicPattern(topicPattern) && topicPattern != "" { return ErrInvalidArgument } if username == "" && topicPattern == "" { diff --git a/server/server_firebase_test.go b/server/server_firebase_test.go index 203960ea..1fdd8a6e 100644 --- a/server/server_firebase_test.go +++ b/server/server_firebase_test.go @@ -15,11 +15,11 @@ type testAuther struct { Allow bool } -func (t testAuther) Authenticate(username, password string) (*auth.User, error) { +func (t testAuther) Authenticate(_, _ string) (*auth.User, error) { return nil, errors.New("not used") } -func (t testAuther) Authorize(user *auth.User, topic string, perm auth.Permission) error { +func (t testAuther) Authorize(_ *auth.User, _ string, _ auth.Permission) error { if t.Allow { return nil }