2019-08-04 10:41:32 -07:00
|
|
|
package accesscontrol
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2020-01-30 22:37:59 -07:00
|
|
|
"github.com/rancher/steve/pkg/schemaserver/server"
|
|
|
|
"github.com/rancher/steve/pkg/schemaserver/types"
|
2019-08-04 10:41:32 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
type AccessControl struct {
|
2020-02-03 14:28:25 -07:00
|
|
|
server.SchemaBasedAccess
|
2019-08-04 10:41:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewAccessControl() *AccessControl {
|
|
|
|
return &AccessControl{}
|
|
|
|
}
|
|
|
|
|
2020-01-30 22:37:59 -07:00
|
|
|
func (a *AccessControl) CanWatch(apiOp *types.APIRequest, schema *types.APISchema) error {
|
2019-08-04 10:41:32 -07:00
|
|
|
access := GetAccessListMap(schema)
|
|
|
|
if !access.Grants("watch", "*", "*") {
|
|
|
|
return fmt.Errorf("watch not allowed")
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|