diff --git a/pkg/clientwrappers/accesspolicies/policies.go b/pkg/clientwrappers/accesspolicies/policies.go index a5fa5b144..87f65a6d0 100644 --- a/pkg/clientwrappers/accesspolicies/policies.go +++ b/pkg/clientwrappers/accesspolicies/policies.go @@ -1,6 +1,8 @@ package accesspolicies import ( + "strings" + "github.com/Orange-OpenSource/nifikop/api/v1alpha1" "github.com/Orange-OpenSource/nifikop/pkg/clientwrappers" "github.com/Orange-OpenSource/nifikop/pkg/common" @@ -28,6 +30,18 @@ func ExistAccessPolicies(client client.Client, accessPolicy *v1alpha1.AccessPoli return false, err } + //special case: if the entity is not the same but e.g. the parent + //entity.Component.Resource = "/data/process-groups/d474577c-0178-1000-ffff-ffffeef1d529" + //accessPolicy.Resource = "/data" + //accessPolicy.ComponentType = "process-groups" + var gottenComponentId = strings.Replace(entity.Component.Resource, "/"+accessPolicy.ComponentType+"/", "", -1) + if string(accessPolicy.Resource) != "/" { + gottenComponentId = strings.Replace(gottenComponentId, string(accessPolicy.Resource), "", -1) + } + if accessPolicy.ComponentId != "" && gottenComponentId != accessPolicy.ComponentId { + return false, nil + } + return entity != nil, nil }