eclipse-tractusx / policy-hub

Policy Hub
Apache License 2.0
3 stars 11 forks source link

Automatic ODRL Policy Template Validation #101

Open jjeroch opened 5 months ago

jjeroch commented 5 months ago

Summary

The policy hub is planning to introduce a new feature called "automatic odrl policy template validation". This feature will allow users or systems to submit ODRL Policy Templates to the policy hub via the REST API. The policy hub will then validate the correctness of the template and provide a response to the user or system.

The possible responses from the policy hub include:

Please note that the policy hub can provide additional responses beyond the ones mentioned above.

Note - a similar implementation exists inside the authority & schema registry - please check the implementation details and likely use similar logic for the policy hub scenario. More information can be found at [this link](https://github.com/eclipse-tractusx/ssi-authority-schema-registry/issues/11).

To support all scenarios the response should never be a html error response. Instead we need an actual Payload information response to the user.

{
"Status": "string - either "OK", "OK under conditions", "NOK""
"Details": [
  {
   "line": "rowxx",
   "message": "string"
   }
 ]
}

Acceptance Criteria


Standard ODRL Structure expected

{
    "@context": {
        "@vocab": "https://w3id.org/edc/v0.0.1/ns/"
    },
    "@id": "<POLICY-ID>",
    "policy": {
        "@context": [
            "https://www.w3.org/ns/odrl.jsonld",
            {
                "cx-policy": "https://w3id.org/catenax/policy/"
            }
        ],
        "@type": "Policy",
        "profile": "cx-policy:profile2405",
        "permission": [
            {
                "action": "use",
                "constraint": {
                    "and": [
                        {
                            "leftOperand": "cx-policy:FrameworkAgreement",
                            "operator": "eq",
                            "rightOperand": "traceability:1.0"
                        },
                        {
                            "leftOperand": "cx-policy:ContractReference",
                            "operator": "eq",
                            "rightOperand": "<individual contract-id>"
                        },
                        {
                            "leftOperand": "cx-policy:UsagePurpose",
                            "operator": "eq",
                            "rightOperand": "cx.core.industrycore:1"
                        }
                    ]
                }
            }
        ]
    }
}

Validation Rules