mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 01:53:33 -06:00
* Move SignedInUser to user service and RoleType and Roles to org * Use go naming convention for roles * Fix some imports and leftovers * Fix ldap debug test * Fix lint * Fix lint 2 * Fix lint 3 * Fix type and not needed conversion * Clean up messages in api tests * Clean up api tests 2
25 lines
572 B
Go
25 lines
572 B
Go
package pipeline
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana/pkg/services/org"
|
|
"github.com/grafana/grafana/pkg/services/user"
|
|
)
|
|
|
|
type RoleCheckAuthorizer struct {
|
|
role org.RoleType
|
|
}
|
|
|
|
func NewRoleCheckAuthorizer(role org.RoleType) *RoleCheckAuthorizer {
|
|
return &RoleCheckAuthorizer{role: role}
|
|
}
|
|
|
|
func (s *RoleCheckAuthorizer) CanSubscribe(_ context.Context, u *user.SignedInUser) (bool, error) {
|
|
return u.HasRole(s.role), nil
|
|
}
|
|
|
|
func (s *RoleCheckAuthorizer) CanPublish(_ context.Context, u *user.SignedInUser) (bool, error) {
|
|
return u.HasRole(s.role), nil
|
|
}
|