From 936e95fd9e39ab9c90a0d4ed525f2b81d7139d4d Mon Sep 17 00:00:00 2001 From: Philipp Heckel Date: Mon, 31 Jan 2022 11:47:30 -0500 Subject: [PATCH] Rename Topic to TopicPattern in Grant --- auth/auth.go | 6 +++--- auth/auth_sqlite.go | 6 +++--- cmd/access.go | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/auth/auth.go b/auth/auth.go index 63201e4b..d14afbf8 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -63,9 +63,9 @@ type User struct { // Grant is a struct that represents an access control entry to a topic type Grant struct { - Topic string - Read bool - Write bool + TopicPattern string // May include wildcard (*) + Read bool + Write bool } // Permission represents a read or write permission to a topic diff --git a/auth/auth_sqlite.go b/auth/auth_sqlite.go index b4ea2ab6..5ff12bf4 100644 --- a/auth/auth_sqlite.go +++ b/auth/auth_sqlite.go @@ -280,9 +280,9 @@ func (a *SQLiteAuth) readGrants(username string) ([]Grant, error) { return nil, err } grants = append(grants, Grant{ - Topic: fromSQLWildcard(topic), - Read: read, - Write: write, + TopicPattern: fromSQLWildcard(topic), + Read: read, + Write: write, }) } return grants, nil diff --git a/cmd/access.go b/cmd/access.go index d46e155e..1e0580ba 100644 --- a/cmd/access.go +++ b/cmd/access.go @@ -145,13 +145,13 @@ func showUsers(c *cli.Context, manager auth.Manager, users []*auth.User) error { } else if len(user.Grants) > 0 { for _, grant := range user.Grants { if grant.Read && grant.Write { - fmt.Fprintf(c.App.ErrWriter, "- read-write access to topic %s\n", grant.Topic) + fmt.Fprintf(c.App.ErrWriter, "- read-write access to topic %s\n", grant.TopicPattern) } else if grant.Read { - fmt.Fprintf(c.App.ErrWriter, "- read-only access to topic %s\n", grant.Topic) + fmt.Fprintf(c.App.ErrWriter, "- read-only access to topic %s\n", grant.TopicPattern) } else if grant.Write { - fmt.Fprintf(c.App.ErrWriter, "- write-only access to topic %s\n", grant.Topic) + fmt.Fprintf(c.App.ErrWriter, "- write-only access to topic %s\n", grant.TopicPattern) } else { - fmt.Fprintf(c.App.ErrWriter, "- no access to topic %s\n", grant.Topic) + fmt.Fprintf(c.App.ErrWriter, "- no access to topic %s\n", grant.TopicPattern) } } } else {