Closed lgblaumeiser closed 3 months ago
@lgblaumeiser thanks for raising this issue!
Presented in the DRAFT Feature Freeze -> Committer is available
supporting additional operators in the BPN permission functions, isNoneOf
amongst others, is probably a good idea, if only for the sake of feature completeness. In fact, there is an issue about it (https://github.com/eclipse-tractusx/tractusx-edc/issues/1426).
However, the same behaviour can already be achieved by using the BusinessPartnerGroupFunction
(documentation). It is the recommended way to define constraints on BPNs, because it does not require updating the policy when the group of BPNs is to be changed.
Specifically, to define an exclusion group, one would simply assign that group to each of the affected BPNs:
curl -X POST <BASEURL>/business-partner-groups \
-d '{
"@context": {
"tx": "https://w3id.org/tractusx/v0.0.1/ns/"
},
"@id": "tx:BPN000001234",
"tx:groups": [
"exclusion_group"
]
}' \
-H "x-api-key: supersecure"
and then declare a policy constraint like this:
{
"@type": "http://www.w3.org/ns/odrl/2/Constraint",
"leftOperand": "https://w3id.org/tractusx/v0.0.1/ns/BusinessPartnerGroup",
"operator": "http://www.w3.org/ns/odrl/2/neq",
"rightOperand": "exclusion_group"
}
then, when more BPNs are to be excluded in the future, it is sufficient to assign them the exclusion_group
and that's it.
@wern Can you comment on Pauls previous comment? In general, there is already everything in place to support your functional need. And actually, using groups is potentially the better way to handle this, as in your proposal you request to address a whole group of BPNs in the policy atom.
Instead of Werner, I answer. We will use Pauls suggestion.
@paullatzelsperger Thanks for your proposal.
@paullatzelsperger
@lgblaumeiser
@wern
We had implemented our feature with BusinessPartnerGroup
, but it doesn't work, because there are some implementation details(i think bugs) in org.eclipse.tractusx.edc.validation.businesspartner.functions.BusinessPartnerGroupFunction#evaluate
which make problems
var bpn = participantAgent.getIdentity();
var groups = store.resolveForBpn(bpn);
// BPN not found in database
if (groups.failed()) {
policyContext.reportProblem(groups.getFailureDetail());
return false;
}
var assignedGroups = groups.getContent();
// BPN was found, but it does not have groups assigned.
if (assignedGroups.isEmpty()) {
policyContext.reportProblem("No groups were assigned to BPN " + bpn);
return false;
}
// right-operand is anything other than String or Collection
var rightOperand = parseRightOperand(rightValue, policyContext);
if (rightOperand == null) {
return false;
}
If the bpn has no groups, the first if
will result to false
, which is not correct for org.eclipse.edc.policy.model.Operator#NEQ
and other cases (use of InMemoryBusinessPartnerStore
, i think the second implementation SqlBusinessPartnerStore
behave the same, not tried, if not the second if
came to the same wrong result)
@saschagr could you file a bug report in the Tx-EDC repo?
Issue found below is addressed in https://github.com/eclipse-tractusx/tractusx-edc/issues/1411, as a solution exists, this is closed
Requestor: @wern
Description
It is currently possible to add a BusinessPartnerNumberConstraint to AccessPolicies or even UsagePolicies (aka. ContractPolicies). However, so far only one operator, namely “eq”, is supported here (see org.eclipse.tractusx.edc.validation.businesspartner.functions.BusinessPartnerNumberPermissionFunction):
What we need here is the ability to define access for ANY OTHER than the BPNs mentioned. In our case: all BPNs that have no biletaral contracts. Having the ability to formulate this in a “negative” way would ease our administration efforts extremely. The additional implementation of the operator “isNoneOf” would be needed to achieve this:
Impact
A simple addon, impact is basically locally and potentially with components that support policy definitions
Additional information