mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 05:21:50 +08:00
25 lines
580 B
Go
25 lines
580 B
Go
package pipeline
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana/pkg/apimachinery/identity"
|
|
"github.com/grafana/grafana/pkg/services/org"
|
|
)
|
|
|
|
type RoleCheckAuthorizer struct {
|
|
role org.RoleType
|
|
}
|
|
|
|
func NewRoleCheckAuthorizer(role org.RoleType) *RoleCheckAuthorizer {
|
|
return &RoleCheckAuthorizer{role: role}
|
|
}
|
|
|
|
func (s *RoleCheckAuthorizer) CanSubscribe(_ context.Context, u identity.Requester) (bool, error) {
|
|
return u.HasRole(s.role), nil
|
|
}
|
|
|
|
func (s *RoleCheckAuthorizer) CanPublish(_ context.Context, u identity.Requester) (bool, error) {
|
|
return u.HasRole(s.role), nil
|
|
}
|