Skip to content
This repository has been archived by the owner on Oct 20, 2022. It is now read-only.

[Fix/NiFiUser] Setting permissions on componentId level #104

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions pkg/clientwrappers/accesspolicies/policies.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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
}

Expand Down