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:
Gabriel MABILLE
2024-02-01 12:37:01 +01:00
committed by GitHub
parent 0f1ba3a9fe
commit 3df0611f81
8 changed files with 80 additions and 11 deletions

View File

@@ -31,6 +31,7 @@ const (
const (
AnonymousNamespaceID = NamespaceAnonymous + ":0"
GlobalOrgID = int64(0)
)
var _ identity.Requester = (*Identity)(nil)
@@ -164,6 +165,19 @@ func (i *Identity) GetPermissions() map[string][]string {
return i.Permissions[i.GetOrgID()]
}
// GetGlobalPermissions returns the permissions of the active entity that are available across all organizations
func (i *Identity) GetGlobalPermissions() map[string][]string {
if i.Permissions == nil {
return make(map[string][]string)
}
if i.Permissions[GlobalOrgID] == nil {
return make(map[string][]string)
}
return i.Permissions[GlobalOrgID]
}
func (i *Identity) GetTeams() []int64 {
return i.Teams
}