mirror of
https://github.com/niusmallnan/steve.git
synced 2025-09-14 13:59:54 +00:00
Full dynamic RBAC and pagination
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"github.com/rancher/steve/pkg/accesscontrol"
|
||||
"github.com/rancher/steve/pkg/schema"
|
||||
"github.com/rancher/steve/pkg/schemaserver/types"
|
||||
"github.com/rancher/steve/pkg/server/store/proxy"
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
)
|
||||
|
||||
func DefaultTemplate(clientGetter proxy.ClientGetter) schema.Template {
|
||||
func DefaultTemplate(clientGetter proxy.ClientGetter, asl accesscontrol.AccessSetLookup) schema.Template {
|
||||
return schema.Template{
|
||||
Store: proxy.NewProxyStore(clientGetter),
|
||||
Store: proxy.NewProxyStore(clientGetter, asl),
|
||||
Formatter: Formatter,
|
||||
}
|
||||
}
|
||||
|
@@ -232,18 +232,25 @@ func (s *Store) getCount(apiOp *types.APIRequest) Count {
|
||||
|
||||
for _, schema := range s.schemasToWatch(apiOp) {
|
||||
gvr := attributes.GVR(schema)
|
||||
access, _ := attributes.Access(schema).(accesscontrol.AccessListByVerb)
|
||||
|
||||
rev := 0
|
||||
itemCount := ItemCount{
|
||||
Namespaces: map[string]int{},
|
||||
}
|
||||
|
||||
all := access.Grants("list", "*", "*")
|
||||
|
||||
for _, obj := range s.ccache.List(gvr) {
|
||||
_, ns, revision, ok := getInfo(obj)
|
||||
name, ns, revision, ok := getInfo(obj)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
if !all && !access.Grants("list", ns, name) && !access.Grants("get", ns, name) {
|
||||
continue
|
||||
}
|
||||
|
||||
if revision > rev {
|
||||
rev = revision
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package resources
|
||||
|
||||
import (
|
||||
"github.com/rancher/steve/pkg/accesscontrol"
|
||||
"github.com/rancher/steve/pkg/client"
|
||||
"github.com/rancher/steve/pkg/clustercache"
|
||||
"github.com/rancher/steve/pkg/schema"
|
||||
@@ -21,8 +22,8 @@ func DefaultSchemas(baseSchema *types.APISchemas, discovery discovery.DiscoveryI
|
||||
return baseSchema
|
||||
}
|
||||
|
||||
func DefaultSchemaTemplates(cf *client.Factory) []schema.Template {
|
||||
func DefaultSchemaTemplates(cf *client.Factory, lookup accesscontrol.AccessSetLookup) []schema.Template {
|
||||
return []schema.Template{
|
||||
common.DefaultTemplate(cf),
|
||||
common.DefaultTemplate(cf, lookup),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user