RBAC: Fix authorize in org (#81552)
* RBAC: Fix authorize in org * Implement option 2 * Fix typo * Fix alerting test * Add test to cover the not member case
This commit is contained in:
@@ -8,6 +8,10 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/auth/identity"
|
||||
)
|
||||
|
||||
const (
|
||||
GlobalOrgID = int64(0)
|
||||
)
|
||||
|
||||
type SignedInUser struct {
|
||||
UserID int64 `xorm:"user_id"`
|
||||
OrgID int64 `xorm:"org_id"`
|
||||
@@ -159,6 +163,19 @@ func (u *SignedInUser) GetPermissions() map[string][]string {
|
||||
return u.Permissions[u.GetOrgID()]
|
||||
}
|
||||
|
||||
// GetGlobalPermissions returns the permissions of the active entity that are available across all organizations
|
||||
func (u *SignedInUser) GetGlobalPermissions() map[string][]string {
|
||||
if u.Permissions == nil {
|
||||
return make(map[string][]string)
|
||||
}
|
||||
|
||||
if u.Permissions[GlobalOrgID] == nil {
|
||||
return make(map[string][]string)
|
||||
}
|
||||
|
||||
return u.Permissions[GlobalOrgID]
|
||||
}
|
||||
|
||||
// DEPRECATED: GetTeams returns the teams the entity is a member of
|
||||
// Retrieve the teams from the team service instead of using this method.
|
||||
func (u *SignedInUser) GetTeams() []int64 {
|
||||
|
||||
Reference in New Issue
Block a user