1
0
mirror of https://github.com/rancher/steve.git synced 2025-09-16 15:29:04 +00:00

RBAC performance improvements

This commit is contained in:
Darren Shepherd
2020-03-01 22:23:36 -07:00
parent 283790802c
commit 6dafed731f
4 changed files with 131 additions and 69 deletions

View File

@@ -58,6 +58,28 @@ func (a *AccessSet) Merge(right *AccessSet) {
}
}
func (a AccessSet) Grants(verb string, gr schema.GroupResource, namespace, name string) bool {
for _, v := range []string{All, verb} {
for _, g := range []string{All, gr.Group} {
for _, r := range []string{All, gr.Resource} {
for k := range a.set[key{
verb: v,
gr: schema.GroupResource{
Group: g,
Resource: r,
},
}] {
if k.Grants(namespace, name) {
return true
}
}
}
}
}
return false
}
func (a AccessSet) AccessListFor(verb string, gr schema.GroupResource) (result AccessList) {
dedup := map[Access]bool{}
for _, v := range []string{All, verb} {