1
0
mirror of https://github.com/rancher/steve.git synced 2025-04-27 11:00:48 +00:00
steve/pkg/accesscontrol/access_control.go

25 lines
489 B
Go
Raw Normal View History

2019-08-04 17:41:32 +00:00
package accesscontrol
import (
"fmt"
2020-01-31 05:37:59 +00:00
"github.com/rancher/steve/pkg/schemaserver/server"
"github.com/rancher/steve/pkg/schemaserver/types"
2019-08-04 17:41:32 +00:00
)
type AccessControl struct {
2020-01-31 05:37:59 +00:00
server.AllAccess
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 {
2019-08-04 17:41:32 +00:00
access := GetAccessListMap(schema)
if !access.Grants("watch", "*", "*") {
return fmt.Errorf("watch not allowed")
}
return nil
}