forked from grafana.jool/grafana-jool
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
528 B
23 lines
528 B
package pipeline
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana/pkg/models"
|
|
)
|
|
|
|
type RoleCheckAuthorizer struct {
|
|
role models.RoleType
|
|
}
|
|
|
|
func NewRoleCheckAuthorizer(role models.RoleType) *RoleCheckAuthorizer {
|
|
return &RoleCheckAuthorizer{role: role}
|
|
}
|
|
|
|
func (s *RoleCheckAuthorizer) CanSubscribe(_ context.Context, u *models.SignedInUser) (bool, error) {
|
|
return u.HasRole(s.role), nil
|
|
}
|
|
|
|
func (s *RoleCheckAuthorizer) CanPublish(_ context.Context, u *models.SignedInUser) (bool, error) {
|
|
return u.HasRole(s.role), nil
|
|
}
|
|
|