mirror of
https://github.com/rancher/steve.git
synced 2025-07-03 01:56:41 +00:00
26 lines
568 B
Go
26 lines
568 B
Go
package accesscontrol
|
|
|
|
import (
|
|
"github.com/rancher/apiserver/pkg/server"
|
|
"github.com/rancher/apiserver/pkg/types"
|
|
"github.com/rancher/steve/pkg/attributes"
|
|
)
|
|
|
|
type AccessControl struct {
|
|
server.SchemaBasedAccess
|
|
}
|
|
|
|
func NewAccessControl() *AccessControl {
|
|
return &AccessControl{}
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|
|
return a.SchemaBasedAccess.CanWatch(apiOp, schema)
|
|
}
|