1
0
Fork 0

Minor optimizations

master
Philip O'Toole 1 year ago
parent fb1e5e3903
commit d2169d8b81

@ -45,13 +45,13 @@ type BasicAuther interface {
// HashCache store hash values for users. Safe for use from multiple goroutines.
type HashCache struct {
mu sync.RWMutex
m map[string]map[string]bool
m map[string]map[string]struct{}
}
// NewHashCache returns a instantiated HashCache
func NewHashCache() *HashCache {
return &HashCache{
m: make(map[string]map[string]bool),
m: make(map[string]map[string]struct{}),
}
}
@ -74,9 +74,9 @@ func (h *HashCache) Store(username, hash string) {
defer h.mu.Unlock()
_, ok := h.m[username]
if !ok {
h.m[username] = make(map[string]bool)
h.m[username] = make(map[string]struct{})
}
h.m[username][hash] = true
h.m[username][hash] = struct{}{}
}
// Credential represents authentication and authorization configuration for a single user.

@ -521,9 +521,9 @@ func Test_AuthPermsAllUsers(t *testing.T) {
t.Fatalf("* has foo perm")
}
if perm := store.HasPerm("username1", "bar"); !perm {
t.Fatalf("username1 does not have bar perm via *")
t.Fatalf("username1 should have bar perm via *")
}
if perm := store.HasPerm("username1", "abc"); !perm {
t.Fatalf("username1 does not have abc perm via *")
t.Fatalf("username1 should have abc perm via *")
}
}

Loading…
Cancel
Save