1
0
mirror of https://github.com/rancher/steve.git synced 2025-04-28 19:24:42 +00:00
steve/pkg/accesscontrol/access_control.go

26 lines
568 B
Go
Raw Normal View History

2019-08-04 17:41:32 +00:00
package accesscontrol
import (
"github.com/rancher/apiserver/pkg/server"
"github.com/rancher/apiserver/pkg/types"
"github.com/rancher/steve/pkg/attributes"
2019-08-04 17:41:32 +00:00
)
type AccessControl struct {
2020-02-03 21:28:25 +00:00
server.SchemaBasedAccess
2019-08-04 17:41:32 +00:00
}
func NewAccessControl() *AccessControl {
return &AccessControl{}
}
2020-01-31 05:37:59 +00:00
func (a *AccessControl) CanWatch(apiOp *types.APIRequest, schema *types.APISchema) error {
if attributes.GVK(schema).Kind != "" {
access := GetAccessListMap(schema)
if _, ok := access["watch"]; ok {
return nil
}
2019-08-04 17:41:32 +00:00
}
return a.SchemaBasedAccess.CanWatch(apiOp, schema)
2019-08-04 17:41:32 +00:00
}