mirror of
https://github.com/niusmallnan/steve.git
synced 2025-07-30 13:40:46 +00:00
test access store
This commit is contained in:
parent
42fab05ed5
commit
2b63f50949
@ -8,6 +8,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
v1 "github.com/rancher/wrangler/pkg/generated/controllers/rbac/v1"
|
v1 "github.com/rancher/wrangler/pkg/generated/controllers/rbac/v1"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"k8s.io/apimachinery/pkg/util/cache"
|
"k8s.io/apimachinery/pkg/util/cache"
|
||||||
"k8s.io/apiserver/pkg/authentication/user"
|
"k8s.io/apiserver/pkg/authentication/user"
|
||||||
)
|
)
|
||||||
@ -48,13 +49,13 @@ func (l *AccessStore) AccessFor(user user.Info) *AccessSet {
|
|||||||
//logrus.Infof("******* AccessFor try cache via key: %s", cacheKey)
|
//logrus.Infof("******* AccessFor try cache via key: %s", cacheKey)
|
||||||
val, ok := l.cache.Get(cacheKey)
|
val, ok := l.cache.Get(cacheKey)
|
||||||
if ok {
|
if ok {
|
||||||
//logrus.Infof("******* AccessFor got cache via key: %s", cacheKey)
|
logrus.Infof("******* AccessFor got cache via key: %s, user: %+v", cacheKey, user)
|
||||||
as, _ := val.(*AccessSet)
|
as, _ := val.(*AccessSet)
|
||||||
return as
|
return as
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//logrus.Info("******* AccessFor generate results")
|
logrus.Info("******* AccessFor generate results")
|
||||||
result := l.users.get(user.GetName())
|
result := l.users.get(user.GetName())
|
||||||
for _, group := range user.GetGroups() {
|
for _, group := range user.GetGroups() {
|
||||||
result.Merge(l.groups.get(group))
|
result.Merge(l.groups.get(group))
|
||||||
@ -63,7 +64,7 @@ func (l *AccessStore) AccessFor(user user.Info) *AccessSet {
|
|||||||
if l.cache != nil {
|
if l.cache != nil {
|
||||||
result.ID = cacheKey
|
result.ID = cacheKey
|
||||||
l.cache.Add(cacheKey, result, 24*time.Hour)
|
l.cache.Add(cacheKey, result, 24*time.Hour)
|
||||||
//logrus.Infof("******* AccessFor add cache to key: %s", cacheKey)
|
logrus.Infof("******* AccessFor add cache to key: %s", cacheKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
Loading…
Reference in New Issue
Block a user