mirror of
https://github.com/binwiederhier/ntfy.git
synced 2024-12-27 12:12:28 +01:00
Allow 'ntfy access --reset'
This commit is contained in:
parent
44bc13eb2c
commit
e56eb0c178
2 changed files with 5 additions and 3 deletions
|
@ -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
|
// 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 (*).
|
// empty) for an entire user. The parameter topicPattern may include wildcards (*).
|
||||||
func (a *SQLiteAuth) ResetAccess(username string, topicPattern string) error {
|
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
|
return ErrInvalidArgument
|
||||||
}
|
}
|
||||||
if username == "" && topicPattern == "" {
|
if username == "" && topicPattern == "" {
|
||||||
|
|
|
@ -15,11 +15,11 @@ type testAuther struct {
|
||||||
Allow bool
|
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")
|
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 {
|
if t.Allow {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue