mirror of
https://github.com/grafana/grafana.git
synced 2024-11-27 11:20:27 -06:00
24 lines
528 B
Go
24 lines
528 B
Go
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
|
|
}
|