11# ODRL policies targeting collections
22
33This document describes how this UMA server supports ODRL collections.
4- The implementation is based on the [ A4DS specification] ( https://spec.knows.idlab.ugent.be/A4DS/L1/latest/ ) .
5- Much of the information in this document can also be found there.
4+ There are 2 main kinds of collections:
5+ custom collections created by a user through the collection API,
6+ and automatically generated collections based on registering resource relations.
67
7- ## WAC / ACP
8+ ## Collection API
89
9- The initial idea for implementing collections is that we want to be able
10- to create policies that target the contents of a container,
11- similar to how WAC and ACP do this.
12- We do not want the UMA server to be tied to the LDP interface though,
13- so the goal is to have a generic solution that can handle any kind of relationship between resources.
10+ The UMA server exposes the collection API through the ` /collections ` URl.
11+ Individual collections can be accessed through ` /collections/{id} ` .
12+ All CRUD operations are supported for both asset and party collections.
1413
15- ## New resource description fields
14+ All requests require authentication as
15+ described in the [ getting started documentation] ( getting-started.md#authenticating-as-resource-owner ) .
1616
17- To support collections, the RS now includes two additional fields when registering a resource,
18- in addition to those defined in the UMA specification.
17+ ### Create
18+
19+ New collections are with POST requests to the collection API.
20+ The request body should be JSON, with the contents depending on the type of collection.
21+ The description field is always optional.
22+
23+ If successful, the response will have status code 201
24+ with the identifier of the new collection in the location header.
25+ This identifier is the full URL to be used when sending requests to update or read this specific collection.
26+
27+ #### Asset collections
28+
29+ ``` json
30+ {
31+ "description" : " My asset collection" ,
32+ "type" : " asset" ,
33+ "parts" : [ " http://example.com/my-resource" , " http://example.com/my-other-resource" ]
34+ }
35+ ```
36+
37+ The identifiers in the ` parts ` array need to be the UMA identifiers of the resources.
38+ The client performing the request needs to be authenticated as the Resource Owner of all resources in the array,
39+ or the request will be rejected.
40+
41+ #### Party collections
42+
43+ ``` json
44+ {
45+ "description" : " My asset collection" ,
46+ "type" : " party" ,
47+ "owners" : [ " http://example.com/alice/card#me" ],
48+ "parts" : [ " http://example.com/alice/card#me" , " http://example.com/bob/card#me" ]
49+ }
50+ ```
51+
52+ The ` owners ` array defines who will be allowed to modify the collection,
53+ and can not be empty.
54+ The client performing the request needs to be one of the owners.
55+
56+ ### Update
57+
58+ A collection can be updated by performing a put request to ` /policies/{id} ` .
59+ This full URL is also the URL that will be returned in the location header when performing a POST request.
60+ The body should be the same as above, and will replace the existing collection.
61+ A collection can only be modified by one of the owners,
62+ in case of an asset collection, this is the owner of the collected resources.
63+
64+ ### Read
65+
66+ All owned collections can be seen by performing a GET request to the collection API.
67+ A single collection can be seen by performing a GET to its specific URL.
68+ A result would look as follows:
69+
70+ ``` ttl
71+ @prefix dc: <http://purl.org/dc/terms/>.
72+ @prefix odrl: <http://www.w3.org/ns/odrl/2/>.
73+
74+ <http://example.com/assets> a odrl:AssetCollection ;
75+ dc:description "My assets" ;
76+ dc:creator <http://example.com/alice/card#me> .
77+ <http://example.com/alice/> odrl:partOf <http://example.com/assets> .
78+ <http://example.com/alice/README> odrl:partOf <http://example.com/assets> .
79+
80+ <http://example.com/party> a odrl:PartyCollection ;
81+ dc:description "My party" ;
82+ dc:creator <http://example.com/alice/card#me> .
83+ <http://example.com/alice/card#me> odrl:partOf <http://example.com/party> .
84+ <http://example.com/bob/card#me> odrl:partOf <http://example.com/party> .
85+ ```
86+
87+ ### Delete
88+
89+ A collection can be removed by performing a DELETE request to the URL of the collection.
90+ Similar to updates, this can only be done by one of the owners.
91+
92+ ## Relation collections
93+
94+ The UMA server will automatically generate collections,
95+ based on [ relation metadata] ( https://spec.knows.idlab.ugent.be/A4DS/L1/latest/#dom-resourcedescription-resource_relations )
96+ provided during resource registration.
97+
98+
99+ ### New resource description fields
100+
101+ To support collections, the RS can include two additional fields when registering a resource.
19102
20103* ` resource_defaults ` : A key/value map describing the scopes of collections having the registered resource as a source.
21104 The keys are the relations where the resource is the subject,
@@ -24,7 +107,6 @@ in addition to those defined in the UMA specification.
24107 The keys are the relations and the values are the UMA IDs of the relation targets.
25108 The resource itself is the object of the relations,
26109 and the values in the arrays are the subject.
27- Note that this is the reverse of the ` resource_defaults ` fields.
28110
29111For both of the above, one of the keys can be ` @reverse ` ,
30112which takes as value a similar key/value object,
@@ -48,20 +130,19 @@ An example of such an extended resource description:
48130
49131The above example tells the UMA server that the available scopes for this new resource are ` read ` and ` write ` ,
50132as defined in the UMA specification.
51- The new field ` resource_defaults ` tells the server that all containers for
52- the ` http://www.w3.org/ns/ldp#contains ` relation
53- that have this resource as the source,
54- have ` read ` as an available scope.
133+ The ` resource_defaults ` field indicates that the collection corresponding to all resources
134+ this resource has the ` http://www.w3.org/ns/ldp#contains ` relation to, have the ` read ` scope.
135+
55136The ` resource_relations ` field indicates that this resource
56- has the ` http://www.w3.org/ns/ldp#contains ` relation with as target ` assets:5678 ` ,
137+ has the ` http://www.w3.org/ns/ldp#contains ` relation with as target ` assets:1234 ` ,
57138while the other entry indicates it is the target of the ` my:other:relation ` with ` assets:5678 ` as subject.
58139
59- ## Generating collection triples
140+ ### Generating collection triples
60141
61142When registering a resource,
62143the UMA server immediately generates all necessary triples to keep track of all collections a resource is part of.
63144First it generates the necessary asset collections based on the ` resource_defaults ` field,
64- and then generate the relation triples based on the ` resource_relations ` field.
145+ and then generates the relation triples based on the ` resource_relations ` field.
65146
66147Assuming a resource ` my:parent:resource ` is registered with a ` http://www.w3.org/ns/ldp#contains ` ` resource_default ` ,
67148the following triples would be generated:
@@ -75,8 +156,7 @@ the following triples would be generated:
75156```
76157If the relation was reversed, the relation object would be ` [ owl:inverseOf <http://www.w3.org/ns/ldp#contains> ] ` .
77158
78-
79- Then, if another resource, ` my:new:resource ` is registered,
159+ Then, if another resource, ` my:new:resource ` , is registered
80160with a reverse ` http://www.w3.org/ns/ldp#contains ` relation targeting ` my:parent:resource ` ,
81161the following additional triple would be generated:
82162``` ttl
@@ -89,15 +169,16 @@ Any policy that targets a collection ID will apply to all resources that are par
89169
90170### Finding collection identifiers
91171
92- Currently, there is no API yet to request a list of all the automatically registered collections described above.
93- As a workaround, the generated collection identifiers are fixed, based on the relevant identifiers.
172+ Collection identifiers can be found through the policy API, described above.
173+ For now, the generated collection identifiers are fixed, based on the relevant identifiers,
174+ but it should be assumed that these can change in the future.
94175A collection with source ` http://example.com/container/ ` and relation ` http://www.w3.org/ns/ldp#contains ` ,
95176would have as collection identifier ` collection:http://example.com/container/:http://www.w3.org/ns/ldp#contains ` .
96177In case of a reverse relationship, this would instead be
97178` collection:http://www.w3.org/ns/ldp#contains:http://example.com/container/ ` .
98179These are the identifiers to then use as targets in a policy.
99180
100- ## Updating collection triples
181+ ### Updating collection triples
101182
102183Every time a resource is updated, the corresponding collection triples are updated accordingly.
103184If an update removes some of the ` resource_relations ` entries,
@@ -134,11 +215,6 @@ To make things easier until that is resolved,
134215the servers are configured so the generated UMA identifiers correspond to the actual resource identifiers.
135216The Resource Server informs the UMA server of the identifiers by using the ` name ` field when registering a resource.
136217
137- ### Asset Collection identifiers
138-
139- [ As mentioned above] ( #finding-collection-identifiers ) , there is no API yet for accessing collections,
140- so a fixed URI format is used for automatically generated collections.
141-
142218### Parent containers not yet registered
143219
144220Resource registration happens asynchronously in the CSS RS implementation.
@@ -152,19 +228,18 @@ where the registration is updated with the now available parent UMA ID.
152228
153229### Accessing resources before they are registered
154230
155- An additional consequence of asynchronous resource registration in the CSS RS,
231+ An additional consequence of asynchronous resource registration in the CSS RS implementation ,
156232is that a client might try to access a resource before its registration is finished.
157233This would cause an error as the Resource Server needs the UMA ID to request a ticket,
158234but doesn't know it yet.
159- To prevent issues, the RS will wait until registration of the corresponding resource is finished,
160- or even start registration should it not have happened yet for some reason.
235+ To prevent issues, the RS will wait until registration of the corresponding resource is finished.
161236A timeout is added to prevent the connection from getting stuck should something go wrong.
162237
163238### Policies for resources that do not yet exist
164239
165240When creating a new resource on the CSS RS, using PUT for example,
166241it is necessary to know if that action is allowed.
167- It is not possible to generate a ticket with this potentially new resource as a target though,
168- as it does not have an UMA ID yet.
242+ It is not possible to generate a ticket with this new resource as a target though,
243+ as it does not have a UMA ID yet.
169244The current implementation instead generates a ticket targeting the first existing (grand)parent container,
170245and requests the ` create ` scope.
0 commit comments