Skip to content

Commit 63d470f

Browse files
committed
feat: Store collection metadata as triples when registering
1 parent b73927a commit 63d470f

File tree

9 files changed

+436
-73
lines changed

9 files changed

+436
-73
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ You can then execute the following flows:
2727
- `yarn script:public`: `GET` the public `/alice/profile/card` without redirection to the UMA server;
2828
- `yarn script:private`: `PUT` some text to the private `/alice/private/resource.txt`, protected by a simple WebID check;
2929
- `yarn script:uma-ucp`: `PUT` some text to the private `/alice/other/resource.txt`, protected by a UCP enforcer checking WebIDs according to policies in `packages/uma/config/rules/policy/`.
30-
- `yarn script:registration`: `POST`, `GET` and `DELETE` some text to/from `/alice/public/resource.txt` to test the correct creation and deletion of resource registrations on the UNA server.
30+
- `yarn script:collection`: `POST`, `GET` and `DELETE` some text to/from `/alice/public/resource.txt` to test the correct creation and deletion of resource registrations on the UMA server.
31+
An AssetCollection policy is used to create `/alice/public/`.
3132

3233
`yarn script:flow` runs all flows in sequence.
3334

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@
6262
"script:demo-test": "yarn exec tsx ./demo/flow-test.ts",
6363
"script:public": "yarn exec tsx ./scripts/test-public.ts",
6464
"script:private": "yarn exec tsx ./scripts/test-private.ts",
65-
"script:registration": "yarn exec tsx ./scripts/test-registration.ts",
65+
"script:collection": "yarn exec tsx ./scripts/test-collection.ts",
6666
"script:uma-ucp": "yarn exec tsx ./scripts/test-uma-ucp.ts",
6767
"script:uma-odrl": "yarn exec tsx ./scripts/test-uma-ODRL.ts",
68-
"script:flow": "yarn run script:public && yarn run script:private && yarn run script:uma-ucp && yarn run script:registration",
68+
"script:flow": "yarn run script:public && yarn run script:private && yarn run script:collection && yarn run script:uma-ucp",
6969
"sync:list": "syncpack list-mismatches",
7070
"sync:fix": "syncpack fix-mismatches"
7171
},

packages/ucp/src/util/Vocabularies.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,18 @@ export function extendVocabulary<TBase extends string, TLocal extends string, TN
106106
export const RDF = createVocabulary(
107107
'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
108108
'type',
109-
);
109+
);
110110

111111

112112
export const ODRL = createVocabulary(
113113
'http://www.w3.org/ns/odrl/2/',
114+
'AssetCollection',
114115
'Agreement',
115116
'Offer',
116117
'Permission',
117118
'Request',
119+
'source',
120+
'partOf',
118121
'action',
119122
'target',
120123
'assignee',
@@ -129,12 +132,18 @@ export const ODRL = createVocabulary(
129132
'gt',
130133
'lt',
131134
'eq',
132-
)
135+
);
136+
137+
export const ODRL_P = createVocabulary(
138+
'https://w3id.org/force/odrl3proposal#',
139+
'relation',
140+
'reverse',
141+
);
133142

134143
export const XSD = createVocabulary(
135144
'http://www.w3.org/2001/XMLSchema#',
136145
'dateTime',
137146
'duration',
138147
'integer',
139148
'string',
140-
);
149+
);

packages/uma/config/policies/authorizers/default.json

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,20 @@
5353
"@type": "OdrlAuthorizer",
5454
"eyePath": { "@id": "urn:uma:variables:eyePath" },
5555
"policies": {
56-
"@id": "urn:uma:default:RulesStorage",
57-
"@type": "DirectoryUCRulesStorage",
58-
"directoryPath": {
59-
"@id": "urn:uma:variables:policyDir"
60-
},
61-
"baseIRI": {
62-
"@id": "urn:uma:variables:policyBaseIRI"
63-
}
56+
"@id": "urn:uma:default:RulesStorage"
6457
}
6558
},
6659
"resourceStore": { "@id": "urn:uma:default:ResourceRegistrationStore" }
60+
},
61+
{
62+
"@id": "urn:uma:default:RulesStorage",
63+
"@type": "DirectoryUCRulesStorage",
64+
"directoryPath": {
65+
"@id": "urn:uma:variables:policyDir"
66+
},
67+
"baseIRI": {
68+
"@id": "urn:uma:variables:policyBaseIRI"
69+
}
6770
}
6871
]
6972
}

packages/uma/config/routes/resources.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
{
77
"@id": "urn:uma:default:ResourceRegistrationHandler",
88
"@type": "ResourceRegistrationRequestHandler",
9-
"resourceStore": { "@id": "urn:uma:default:ResourceRegistrationStore" }
9+
"resourceStore": { "@id": "urn:uma:default:ResourceRegistrationStore" },
10+
"policies": { "@id": "urn:uma:default:RulesStorage" }
1011
},
1112
{
1213
"@id": "urn:uma:default:ResourceRegistrationRoute",

packages/uma/config/rules/policy/policy0.ttl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@prefix ex: <http://example.org/1707120963224#> .
22
@prefix odrl: <http://www.w3.org/ns/odrl/2/> .
3+
@prefix odrl_p: <https://w3id.org/force/odrl3proposal#> .
34

45
ex:usagePolicy a odrl:Agreement .
56
ex:usagePolicy odrl:permission ex:permission .
@@ -16,3 +17,15 @@ ex:permission2 odrl:action odrl:create , odrl:modify .
1617
ex:permission2 odrl:target <alice/> , <alice/private/> , <alice/private/resource.txt> .
1718
ex:permission2 odrl:assignee <https://woslabbi.pod.knows.idlab.ugent.be/profile/card#me> .
1819
ex:permission2 odrl:assigner <https://pod.woutslabbinck.com/profile/card#me> .
20+
21+
ex:usagePolicy3 a odrl:Agreement .
22+
ex:usagePolicy3 odrl:permission ex:permission3 .
23+
ex:permission3 a odrl:Permission .
24+
ex:permission3 odrl:action odrl:read .
25+
ex:permission3 odrl:target <collection:alice/> .
26+
ex:permission3 odrl:assignee <https://woslabbi.pod.knows.idlab.ugent.be/profile/card#me> .
27+
ex:permission3 odrl:assigner <https://pod.woutslabbinck.com/profile/card#me> .
28+
29+
<collection:alice/> a odrl:AssetCollection ;
30+
odrl:source <alice/> ;
31+
odrl_p:relation <http://www.w3.org/ns/ldp#contains> .

0 commit comments

Comments
 (0)