You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,6 +30,8 @@ You can then execute the following flows:
30
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
31
An AssetCollection policy is used to create `/alice/public/`.
32
32
More information on the collection implementation can be found in [documentation/collections.md](documentation/collections.md).
33
+
-`yarn script:uma-odrl-policy`: Tests all policy management APIs.
34
+
-`yarn script:uma-odrl-end2end`: Tests the access request management APIs
33
35
34
36
`yarn script:flow` runs all flows in sequence.
35
37
@@ -39,6 +41,9 @@ the above scripts are the best way to learn about how everything works.
39
41
A more extensive getting started guide can be found
40
42
in [documentation/getting-started.md](documentation/getting-started.md).
41
43
44
+
More information on policy management can be found in
Copy file name to clipboardExpand all lines: documentation/policy-management.md
+69-73Lines changed: 69 additions & 73 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
# Policy Management
2
2
3
-
In this document we describe the *policy adminstration endpoint*.
4
-
It contains the methods to describe how to create, read, update and delete policies.
3
+
The *policy management API* allows users to configure the policies that govern access to their data.
4
+
First we cover the available operations, after which we cover the known issues and limitations of the API.
5
5
6
-
## Supported endpoints
6
+
## API
7
7
8
-
The current implementation supports the following requests:
8
+
The current implementation supports the following requests on the UMA server:
9
9
10
10
-[`GET`](#reading-policies) to both `uma/policies` and `uma/policies/<encodedPolicyID>`
11
11
-[`POST`](#creating-policies) to `uma/policies`
@@ -15,13 +15,15 @@ The current implementation supports the following requests:
15
15
16
16
These requests comply with some restrictions:
17
17
18
-
- When the URL contains a policy ID, it must be [URI encoded](#uri-encoding-decision).
19
-
- The request must have its `'Authorization'` header set to the clients webID. More on that [later](#authorizationauthentication-decisions).
18
+
- When the URL contains a policy ID, it must be URI encoded.
19
+
- The request must have its `Authorization` header set to the owners WebID.
20
+
More on that [later](#authentication).
20
21
21
22
### Creating policies
22
23
23
24
Create a policy/multiple policies through a POST request to `/uma/policies`.
24
-
Apart from its Authorization header, the `'Content-Type'` must be set to the RDF serialization format in which the body is written.
25
+
Apart from its Authorization header, the `'Content-Type'` must be set
26
+
to the RDF serialization format in which the body is written.
25
27
The accepted formats are those accepted by the [N3 Parser](https://github.com/rdfjs/N3.js/?tab=readme-ov-file#parsing), represented by the following content types:
26
28
27
29
-`text/turtle`
@@ -30,7 +32,9 @@ The accepted formats are those accepted by the [N3 Parser](https://github.com/rd
30
32
-`application/n-quads`
31
33
-`text/n3`
32
34
33
-
The body is expected to represent a valid ODRL policy, although some [sanitization](#sanitization-decisions) is applied to ensure minimal validity. It is possible to POST multiple policies at once, but they have to remain in scope of the client.
35
+
The body is expected to represent a valid ODRL policy,
36
+
although some [sanitization](#sanitization-decisions) is applied to ensure minimal validity.
37
+
It is possible to POST multiple policies at once, but they have to remain in scope of the owner.
34
38
Upon success, the server responds with **status code 201**.
35
39
Bad requests, possibly due to an improper policy definition, will respond with **status code 400 or 409**.
36
40
When the policy has been validated, but adding it to the storage fails, the response will have **status code 500**.
@@ -61,22 +65,24 @@ ex:permission a odrl:Permission ;
61
65
62
66
To read policies, two endpoints are implemented:
63
67
64
-
- GET `/uma/policies`: get policy information you are authorized to see, for every policy.
65
-
- GET `/uma/policies/<encodedPolicyID>`: get policy information you are authorized to see, for the policy with the specified [URI encoded](#uri-encoding-decision) ID.
68
+
- GET `/uma/policies`: return all policies the provided credentials have assigned.
69
+
- GET `/uma/policies/<encodedPolicyID>`: return the rules of the policy with the given (encoded) ID,
70
+
if the provided credentials are allowed to see them.
66
71
67
-
These endpoints returen both the policies (and related rules) where the user is identified as the assigner and assignee.
68
-
Applications should be aware of this and should make sure the distinction is made where necessary.
72
+
One policy can contain rules of multiple assigners,
73
+
only the rules where the assigner matches the request credentials will be returned.
69
74
70
75
#### GET one policy
71
76
72
-
An example request to get policy `http://example.org/policy` for the client with webID `https://pod.example.com/profile/card#me` looks like this:
77
+
An example request to get policy `http://example.org/policy`
78
+
with WebID `https://pod.example.com/profile/card#me` looks like this:
Updating a policy can be done through a PUT or a PATCH request to `/uma/policies/<encodedPolicyID>`, each with different semantics.
108
+
Updating a policy can be done through a PUT or a PATCH request to `/uma/policies/<encodedPolicyID>`,
109
+
each with different semantics.
103
110
104
111
#### PUT
105
112
106
-
A PUT completely replaces the policy within the scope of the client.
107
-
The PUT works as a combination of DELETE and POST. It requires a body with the same content type as the [POST request](#creating-policies). This body will be interpreted as the requested policy with some rules.
113
+
A PUT completely replaces all rules of a policy the client is the assigner of.
114
+
The PUT works as a combination of DELETE and POST.
115
+
It requires a body with the same content type as the [POST request](#creating-policies).
116
+
This body will be interpreted as the requested policy with some rules.
108
117
109
118
The PUT process:
110
119
111
-
1. Find information about the policy. If it does not exist, return with a **status code 404** to indicate that you cannot rewrite a nonexistent policy.
120
+
1. Find information about the policy.
121
+
If it does not exist, return with a **status code 404** to indicate that you cannot rewrite a nonexistent policy.
112
122
113
-
2. Parse and validate the body, with the same procedure used in the POST endpoint. First, we perform the basic sanitization checks. Upon success, extra checks are performed to see if the new definition stays within the scope of the client:
123
+
2. Parse and validate the body, with the same procedure used in the POST endpoint.
124
+
First, we perform the basic sanitization checks.
125
+
Upon success, extra checks are performed to see if the new definition stays within the scope of the client:
114
126
- Check that the newly defined policy does not define other policies
115
127
- Check that the new policy does not contain any rules that do not belong to the client
116
128
- Check that no unrelated quads to the policy and its rules are added.
117
129
118
130
Failed checks will result in a response with **status code 400** and a dedicated message.
119
-
3. Delete the old policy, but keep a copy for a possible rollback. The deletion uses the procedure used in the [DELETE](#deleting-policies) endpoint.
131
+
3. Delete the old policy, but keep a copy for a possible rollback.
132
+
The deletion uses the procedure used in the [DELETE](#deleting-policies) endpoint.
120
133
121
134
4. Add the new policy. On success, the server will respond with **status code 204** .
122
-
Upon failure, the server will respond with a 5xx error status.
135
+
Upon failure, the server will respond with a 5xx error status.
123
136
124
137
##### Example PUT Request
125
138
@@ -143,21 +156,20 @@ ex:permission a odrl:Permission ;
This example updates the target of this policy. It is important to explicitly include `-X PUT`, as curl will otherwise default to a POST request, which is invalid for this endpoint.
147
-
148
159
#### PATCH
149
160
150
161
A PATCH request will update the policy and its related rules using a SPARQL update query.
151
162
The `content-type` header must be set to `application/sparql-update`.
152
163
153
164
The policy will be isolated from the store before executing the query, to make sure no other quads are affected.
154
-
In addition, the user's credentials are checked to make sure they are the resource owner for the resource targeted in the policy.
155
165
After this, the query can be executed.
156
-
To make sure the policy remains a valid policy, the policy is isolated and checked again before inserting the modified store back in the store.
166
+
To make sure the policy remains a valid policy, the policy is isolated and checked again
167
+
before inserting the modified store back in the store.
157
168
158
169
##### Example PATCH request
159
170
160
-
The example below illustrates how policies can be changed using a PATCH request. We notice that the content type has changed to `application/sparql-query`.
171
+
The example below illustrates how policies can be changed using a PATCH request.
172
+
Notice that the content type has changed to `application/sparql-query`.
The current implementation has insufficient authentication restrictions. Currently, the only requirement is that the 'Authorization' header is to be set to the webID of the "logged on" client. Proper procedures to authenticate this client are still to be implemented.
207
+
Current authentication is done by setting the `Authorization` header to a WebID.
208
+
There is no verification so any WebID can be entered.
209
+
In the future we want to support OIDC tokens for authentication.
196
210
197
-
### Sanitization decisions
211
+
### Sanitization
198
212
199
-
Some endpoints allow new policies to be created, or existing policies to be modified. This introduces the possibility of invalid syntactic or semantic policies, hence a sanitization strategy is required. In the current implementation, only POST, PUT and PATCH could introduce such problems. We provided the following basic checks:
213
+
New policies and policy updates are sanitized with the following checks:
200
214
201
-
- Every defined rule must have a unique ID.
215
+
- Every defined rule must have a unique ID (`odrl:uid`).
202
216
- Every rule must have exactly one assigner.
203
-
- Every assigner must match the authenticated client.
204
-
205
-
Sanitization Limitations
206
-
207
-
- There are currently no checks to verify whether a client is sufficiently authorized to create or modify a policy/rule for a specific target.
208
-
- A client should not be in able to alter rights about a target it does not have access to.
209
-
- There are plenty of other sanitization checks to be considered.
210
-
211
-
### URI encoding decision
212
-
213
-
Some operations require the client to specify a policy ID in the URL. Since policy ID's might contain reserved characters (e.g. `/`, `:`, ...), we have chosen to encode them with the builtin [`encodeURIComponent()` function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent). Using this method, reserved characters will be converted to their respective UTF-8 encodings.
214
-
215
-
## Testing
216
-
217
-
The current implementation is tested only by the script in `scripts\test-uma-ODRL-policy.ts`. This script tests every implemented endpoint with a designated flow. Since the script initiates with an empty storage, and there is no endpoint or other way to seed it, the first requests must test the POST endpoint. These tests are designed to ensure that the storage is filled. After the POST tests, the access endpoints can be tested. Every endpoint gets tested in this script, which makes sure that the added data is removed. The current testing will be replaced with proper unit tests and integration tests in the near future.
218
-
219
-
## TODO
220
-
221
-
- The current [sanitization limitations](#sanitization-decisions) are to be considered.
222
-
- Implement Unit Tests
223
-
- ...
224
-
225
-
### Solved Problems
226
-
227
-
#### DELETE fix
228
-
229
-
##### Problem
230
-
231
-
When you have a policy with multiple rules that have different assigners, DELETE on every rule of one assigner will succesfully delete the rule itself, but not the definition of the rule within the policy. This is due to the fact that you can currently only DELETE based on the ID of the rule/policy you want to delete, and you cannot delete the entire policy since other assigners depend on it. Currently, the only problem with this is filling space, since the quads defining deleted rules will not be returned in GET requests.
232
-
233
-
##### Fix
217
+
- The assigner must match the authenticated WebID.
234
218
235
-
We created a new RulesStorage function, made specifically to fix our problem entirely. The function is implemented to delete the rule AND its definition in the policy. This solution is still a bit experimental.
219
+
The sanitization check is quite limited and will not prevent all invalid policies.
220
+
On the other hand, it is not able to handle some triples that are valid,
221
+
such as collection definitions.
236
222
237
-
#### PATCH fix
223
+
###Ownership
238
224
239
-
PATCH used to contain a safety hazard. When client A has a certain policy/rule, or even just a certain quad, this could be discovered by an intrusive client B. Client B could simply PATCH an INSERT of a random quad that does NOT belong to its own rules/policies, which can have one of three outcomes:
225
+
There is no ownership check to make sure users can only write policies they own.
226
+
This will require changes to the resource server as currently it does not inform the UMA server of ownership.
240
227
241
-
1. The PATCH resolves in an error saying that you cannot change rules that do not belong to you. This means that the quad belongs to some other client, since it has been detected as a quad owned by someone else.
228
+
### PATCH limitations
242
229
243
-
2. The PATCH resolves in an error saying that you cannot change rules that belong to nobody. This means that the quad is not affiliated with any client.
230
+
PATCH only works on simple policies without constraints.
231
+
There is a known issue where nested triples, such as constraints, can get lost when modifying a policy.
244
232
245
-
3. The PATCH completes with code 200. Since the inserted quad does NOT belong to you, there must be another client that owns the quad. In this way, any policy can be discovered (exhaustively).
246
-
An extra constraint, disabling clients to PATCH policies it has no rules in, would still enable the client to exploit policies that it has rules in.
233
+
### PUT identifier validation
247
234
248
-
This problem was solved by splitting the policy into the parts where the client has access to, and the parts where it does not. By executing the query only on the parts that the client has access to, it would be easier to analyse the resulting store of the query. If this store has rules that the client does not have access to, they must have been added by the client and the operation gets cancelled. This method is also protected from deleting rules out of our reach.
235
+
The identifier is not validated correctly when doing a PUT request.
236
+
This means that the identifier of the policy you are PUTting does not need to match the identifier in the URL.
237
+
The policy that gets modified is based on the identifier found in the policy.
249
238
250
-
#### POST checks
239
+
###Policies with multiple assigners
251
240
252
-
It is now impossible to POST an already existing policy or already existing rules. This means that a policy can only be POSTED once. If a client wishes to be a part of a policy, it has to do it through a PUT request. If a client is already part of the policy, it can PATCH modifications.
241
+
It is possible to have a policy with several rules,
242
+
which have different assigners.
243
+
Some known issues there:
244
+
- When GETting such a policy, you will only receive the identifiers of all linked rules,
245
+
even those you are not the assigner of.
246
+
You will not get the contents of those rules though.
247
+
- When DELETEing such a policy, all rules will be deleted,
0 commit comments