-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from wistefan/ngsi-ld
add some basic ngsi-ld support
- Loading branch information
Showing
10 changed files
with
232 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package ngsild.leftOperand | ||
|
||
import rego.v1 | ||
|
||
|
||
# helper method to retrieve the type from the path | ||
type_from_path(path) := tfe if { | ||
path_without_query := split(path, "?")[0] | ||
path_elements := split(path_without_query, "/") | ||
id_elements := split(path_elements[count(path_elements) - 1], ":") | ||
tfe = id_elements[2] | ||
} else := tfq if { | ||
query := split(path, "?")[1] | ||
query_parts := split(query, "&") | ||
type_query := [query_part | some query_part in query_parts; contains(query_part, "type=")] | ||
tfq = split(type_query[0], "=")[1] | ||
} | ||
|
||
# helper to retrieve the type from the body | ||
type_from_body(body) := body.type | ||
|
||
## ngsi-ld:entityType | ||
# retrieves the type from an entity, either from the request path or from the body | ||
entity_type(http_part) := tfp if { | ||
tfp = type_from_path(http_part.path) | ||
} else := tfb if { | ||
tfb = type_from_body(http_part.body) | ||
} | ||
|
||
## ngsi-ld:<property> | ||
# retrieves the value of the property, only applies to properties of type "Property". The method should be concretized in the mapping.json, to match a concrete property. | ||
# F.e.: ngsi-ld:brandName = property_value("brandName", http_part.body) | ||
property_value(property_name, body) := body[property_name].value | ||
|
||
## ngsi-ld:<property>_observedAt | ||
# retrieves the observedAt of the property The method should be concretized in the mapping.json, to match a concrete property. | ||
# F.e.: ngsi-ld:brandName_observedAt = property_value("brandName", http_part.body) | ||
property_observed_at(property_name,body) := body[property_name].observedAt | ||
|
||
## ngsi-ld:<property>_modifiedAt | ||
# retrieves the modifiedAt of the property The method should be concretized in the mapping.json, to match a concrete property. | ||
# F.e.: ngsi-ld:brandName_modifiedAt= property_value("brandName", http_part.body) | ||
property_observed_at(property_name,body) := body[property_name].modifiedAt | ||
|
||
## ngsi-ld:<relationship> | ||
# retrieves the object of the relationship, only applies to properties of type "Relationship". The method should be concretized in the mapping.json, to match a concrete property. | ||
# F.e.: ngsi-ld:owningCompany = relationship_object("owningCompany", http_part.body) | ||
relationship_object(relationship_name, body):= body[relationship_name].object | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package vc.leftOperand | ||
|
||
import rego.v1 | ||
|
||
## vc:role | ||
# retrieves the roles from the credential, that target the current organization | ||
role(verifiable_credential,organization_id) := r if { | ||
roles := verifiable_credential.credentialSubject.roles | ||
role := [rad | some rad in roles; rad.target = organization_id ] | ||
r = role[_].names; trace(organization_id) | ||
} | ||
|
||
## vc:currentParty | ||
# the current (organization)party, | ||
current_party(credential) := credential.issuer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"@context": { | ||
"dc": "http://purl.org/dc/elements/1.1/", | ||
"dct": "http://purl.org/dc/terms/", | ||
"owl": "http://www.w3.org/2002/07/owl#", | ||
"odrl": "http://www.w3.org/ns/odrl/2/", | ||
"rdfs": "http://www.w3.org/2000/01/rdf-schema#", | ||
"skos": "http://www.w3.org/2004/02/skos/core#" | ||
}, | ||
"@id": "https://mp-operation.org/policy/common/type", | ||
"@type": "odrl:Policy", | ||
"odrl:permission": { | ||
"odrl:assigner": { | ||
"@id": "https://www.mp-operation.org/" | ||
}, | ||
"odrl:target": { | ||
"@type": "odrl:AssetCollection", | ||
"odrl:source": "urn:asset", | ||
"odrl:refinement": [ | ||
{ | ||
"@type": "odrl:Constraint", | ||
"odrl:leftOperand": { | ||
"@id": "ngsi-ld:entityType" | ||
}, | ||
"odrl:operator": { | ||
"@id": "odrl:eq" | ||
}, | ||
"odrl:rightOperand": "Marketplace" | ||
} | ||
] | ||
}, | ||
"odrl:assignee": { | ||
"@id": "odrl:any" | ||
}, | ||
"odrl:action": { | ||
"@id": "dome-op:read" | ||
} | ||
} | ||
} |