Dashboard/Folder permission fix session (#47174)
* Fix inherited scopes for dashboard to use folder uid * Add inherited evaluators * Slight modification of the commments * Add test for inheritance * Nit. * extract shared function from tests * Nit. Extra line * Remove unused comment Co-authored-by: Karl Persson <kalle.persson@grafana.com> Co-authored-by: gamab <gabi.mabs@gmail.com>
This commit is contained in:
co-authored by
Karl Persson
gamab
parent
910ed77e16
commit
90a94eab74
@@ -143,7 +143,7 @@ func (s *ScopeResolver) GetResolveAttributeScopeMutator(orgID int64) ScopeMutato
|
||||
var err error
|
||||
// By default the scope remains unchanged
|
||||
resolvedScope := scope
|
||||
prefix := scopePrefix(scope)
|
||||
prefix := ScopePrefix(scope)
|
||||
if fn, ok := s.attributeResolvers[prefix]; ok {
|
||||
resolvedScope, err = fn(ctx, orgID, scope)
|
||||
if err != nil {
|
||||
@@ -157,10 +157,10 @@ func (s *ScopeResolver) GetResolveAttributeScopeMutator(orgID int64) ScopeMutato
|
||||
}
|
||||
}
|
||||
|
||||
// scopePrefix returns the prefix associated to a given scope
|
||||
// ScopePrefix returns the prefix associated to a given scope
|
||||
// we assume prefixes are all in the form <resource>:<attribute>:<value>
|
||||
// ex: "datasources:name:test" returns "datasources:name:"
|
||||
func scopePrefix(scope string) string {
|
||||
func ScopePrefix(scope string) string {
|
||||
parts := strings.Split(scope, ":")
|
||||
// We assume prefixes don't have more than maxPrefixParts parts
|
||||
if len(parts) > maxPrefixParts {
|
||||
|
||||
Reference in New Issue
Block a user