Skip to content

Commit 71b02d2

Browse files
feat: usage control policies package (#3)
Signed-off-by: Wouter Termont <wouter.termont@ugent.be>
1 parent d7e0310 commit 71b02d2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3787
-1547
lines changed

.yarnrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ nodeLinker: "node-modules"
2727
# "@types/node": ^18
2828
# winston@*:
2929
# dependencies:
30-
# "@types/node": ^18
30+
# "@types/node": ^18

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ This repository contains SolidLab research artefacts on use of UMA in the Solid
1010

1111
- [`@solidlab/uma-css`](packages/css): UMA modules for the [Community Solid Server](https://github.com/CommunitySolidServer/CommunitySolidServer/).
1212

13+
- [`@solidlab/ucp`](packages/ucp): Usage Control Policy decision/enforcement component.
1314

1415
## Getting started
1516

1617
In order to run this project you need to perform the following steps.
1718

18-
1. Ensure that you are using Node.js 18.18 or higher with Yarn 4.0 or higher.
19+
1. Ensure that you are using Node.js 18.18 or higher, e.g. by running `nvm use`.
20+
1. Enable Node.js Corepack with `corepack enable`.
1921
1. Run `yarn install` in the project root (this will automatically call `yarn build:all`).
2022
1. Run `yarn start:all`.
2123

@@ -24,15 +26,31 @@ This will boot up a UMA server and compatible Community Solid Server instance.
2426
You can then execute the following flows:
2527

2628
- `yarn script:public`: `GET` the public `/alice/profile/card` without redirection to the UMA server;
27-
- `yarn script:private`: `PUT` some text to the private `/alice/private/resource.txt`, with redirection to the UMA server;
28-
- `yarn script:registration`: `POST`, `GET` and `DELETE` some text `/alice/public/resource.txt` without redirection to the UMA server, to test the correct creation and deletion of resource registrations on the UNA server.
29+
- `yarn script:private`: `PUT` some text to the private `/alice/private/resource.txt`, protected by a simple WebID check;
30+
- `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/`.
31+
- `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.
32+
- `yarn script:ucp-enforcement`: Run the UCP enforcer in a script (`scripts/test-ucp-enforcement.ts`). This does not need the servers to be started.
2933

3034
`yarn script:flow` runs all flows in sequence.
3135

3236
## Implemented features
3337

3438
The packages in this project currently only support a fixed UMA AS per CSS RS, and contain only the trivial [AllAuthorizer](packages/uma/src/models/AllAuthorizer.ts) that allows all access. More useful features are coming soon ...
3539

40+
### Usage control policy enforcement
41+
42+
Used for creating a modular engine that calculates which access modes are granted based on:
43+
44+
- Usage Control Rules
45+
- Interpretation of those rules
46+
- The request of the Requested Party together with all its claims
47+
48+
For more information, you can check out its [own repository](https://github.com/woutslabbinck/ucp-enforcement) which has three engines that use [ODRL rules](https://www.w3.org/TR/odrl-model/).
49+
50+
A test script is provided for a CRUD ODRL engine: `yarn script:ucp-enforcement`.
51+
In the [script](./scripts/test-ucp-enforcement.ts) a read Usage Control Rule (in ODRL) is present together with N3 interpretation rules.
52+
Then a read request is performed using the engine, which results in a list of grants. This list is then printed to the console.
53+
3654

3755
## Next steps
3856

package.json

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@solidlab/user-managed-access",
33
"version": "0.1.0",
4-
"description": "UMA artefacts for use in the Solid ecosystem.",
4+
"description": "SolidLab access & usage control artefacts for use in the Solid ecosystem.",
55
"keywords": [
66
"css",
77
"solid",
@@ -10,20 +10,26 @@
1010
"uma",
1111
"user managed access",
1212
"access control",
13+
"usage control",
1314
"authorization",
1415
"policies",
1516
"grants"
1617
],
1718
"author": {
1819
"name": "Wouter Termont",
1920
"email": "wouter.termont@ugent.be",
20-
"url": "https://wouter.termont.online"
21+
"url": "https://wouter.termont.online/"
2122
},
2223
"license": "MIT",
2324
"repository": "github:SolidLabResearch/user-managed-access",
2425
"homepage": "https://github.com/SolidLabResearch/user-managed-access/README.md",
2526
"bugs": "https://github.com/SolidLabResearch/user-managed-access/issues",
2627
"contributors": [
28+
{
29+
"name": "Ruben Dedecker",
30+
"email": "ruben.dedecker@ugent.be",
31+
"url": "https://pod.rubendedecker.be/profile/card#me"
32+
},
2733
{
2834
"name": "Wout Slabbink",
2935
"email": "wout.slabbink@ugent.be",
@@ -32,11 +38,11 @@
3238
{
3339
"name": "Wouter Termont",
3440
"email": "wouter.termont@ugent.be",
35-
"url": "https://wouter.termont.online"
41+
"url": "https://wouter.termont.online/"
3642
}
3743
],
3844
"private": true,
39-
"packageManager": "yarn@4.0.2",
45+
"packageManager": "yarn@4.1.0",
4046
"engines": {
4147
"node": ">=18.18",
4248
"yarn": ">=4.0"
@@ -53,11 +59,14 @@
5359
"script:public": "yarn exec ts-node ./scripts/test-public.ts",
5460
"script:private": "yarn exec ts-node ./scripts/test-private.ts",
5561
"script:registration": "yarn exec ts-node ./scripts/test-registration.ts",
56-
"script:flow": "yarn run script:public && yarn run script:private && yarn run script:registration"
62+
"script:ucp-enforcement": "yarn exec ts-node ./scripts/test-ucp-enforcement.ts",
63+
"script:uma-ucp": "yarn exec ts-node ./scripts/test-uma-ucp.ts",
64+
"script:flow": "yarn run script:public && yarn run script:private && yarn run script:uma-ucp && yarn run script:registration && yarn run script:ucp-enforcement"
5765
},
5866
"devDependencies": {
5967
"@commitlint/cli": "^16.1.0",
6068
"@commitlint/config-conventional": "^16.0.0",
69+
"@solidlab/ucp": "workspace:^",
6170
"@types/jest": "^29.5.6",
6271
"@types/node": "^20.9.4",
6372
"@typescript-eslint/eslint-plugin": "^5.12.1",
@@ -67,6 +76,7 @@
6776
"eslint": "^8.10.0",
6877
"jest": "^29.7.0",
6978
"lerna": "^4.0.0",
79+
"koreografeye": "^0.4.8",
7080
"shx": "^0.3.3",
7181
"ts-jest": "^29.1.1",
7282
"ts-node": "^10.9.1",

packages/css/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"author": {
1818
"name": "Wouter Termont",
1919
"email": "wouter.termont@ugent.be",
20-
"url": "https://wouter.termont.online"
20+
"url": "https://wouter.termont.online/"
2121
},
2222
"license": "MIT",
2323
"repository": "github:SolidLabResearch/user-managed-access",
@@ -32,7 +32,7 @@
3232
{
3333
"name": "Wouter Termont",
3434
"email": "wouter.termont@ugent.be",
35-
"url": "https://wouter.termont.online"
35+
"url": "https://wouter.termont.online/"
3636
}
3737
],
3838
"private": true,

packages/css/src/authorization/UmaPermissionReader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class UmaPermissionReader extends PermissionReader {
4141
return [scope, false];
4242
}
4343

44-
return [scope, true];
44+
return [scope.replace('urn:example:css:modes:', ''), true];
4545
}));
4646

4747
result.set({ path: resource_id }, permissionSet);

packages/css/src/uma/ResourceRegistrar.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { ResourceIdentifier, MonitoringStore, KeyValueStorage } from '@solid/community-server';
2-
import { AS, getLoggerFor, StaticHandler } from '@solid/community-server';
2+
import { AccessMode, AS, getLoggerFor, StaticHandler } from '@solid/community-server';
33
import { OwnerUtil } from '../util/OwnerUtil';
44
import { fetchUmaConfig } from './util/UmaConfigFetcher.js';
55
import { ResourceDescription } from '@solidlab/uma';
@@ -34,7 +34,15 @@ export class ResourceRegistrar extends StaticHandler {
3434

3535
const { resource_registration_endpoint: endpoint } = await fetchUmaConfig(issuer);
3636

37-
const description: ResourceDescription = { resource_scopes: [ 'CRUD' ] };
37+
const description: ResourceDescription = {
38+
resource_scopes: [
39+
'urn:example:css:modes:read',
40+
'urn:example:css:modes:append',
41+
'urn:example:css:modes:create',
42+
'urn:example:css:modes:delete',
43+
'urn:example:css:modes:write',
44+
]
45+
};
3846

3947
this.logger.info(`Creating resource registration for <${resource.path}> at <${endpoint}>`);
4048

packages/css/src/uma/util/PermissionTicketFetcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export async function fetchPermissionTicket(
1919
for (const [ target, modes ] of permissions.entrySets()) {
2020
body.push({
2121
resource_id: target.path,
22-
resource_scopes: Array.from(modes)
22+
resource_scopes: Array.from(modes).map(mode => `urn:example:css:modes:${mode}`)
2323
});
2424
}
2525

packages/ucp/package.json

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"name": "@solidlab/ucp",
3+
"version": "0.1.0",
4+
"description": "A Usage Control Policy decision/enforcement component.",
5+
"keywords": [
6+
"access control",
7+
"usage control",
8+
"authorization",
9+
"policies",
10+
"grants"
11+
],
12+
"author": {
13+
"name": "Wout Slabbinck",
14+
"email": "wout.slabbinck@ugent.be",
15+
"url": "https://woutslabbinck.com"
16+
},
17+
"license": "MIT",
18+
"repository": "github:SolidLabResearch/user-managed-access",
19+
"homepage": "https://github.com/SolidLabResearch/user-managed-access/README.md",
20+
"bugs": "https://github.com/SolidLabResearch/user-managed-access/issues",
21+
"contributors": [
22+
{
23+
"name": "Wout Slabbink",
24+
"email": "wout.slabbink@ugent.be",
25+
"url": "https://pod.woutslabbinck.com/profile/card#me"
26+
},
27+
{
28+
"name": "Wouter Termont",
29+
"email": "wouter.termont@ugent.be",
30+
"url": "https://wouter.termont.online/"
31+
}
32+
],
33+
"private": true,
34+
"packageManager": "yarn@4.0.2",
35+
"engines": {
36+
"node": ">=18.18",
37+
"yarn": ">=4.0"
38+
},
39+
"main": "./dist/index.js",
40+
"types": "./dist/index.d.ts",
41+
"exports": {
42+
"./package.json": "./package.json",
43+
".": {
44+
"require": "./dist/index.js"
45+
}
46+
},
47+
"files": [
48+
"dist",
49+
"config"
50+
],
51+
"scripts": {
52+
"build": "yarn build:ts",
53+
"build:ts": "yarn run -T tsc"
54+
},
55+
"dependencies": {
56+
"@types/n3": "^1.16.3",
57+
"koreografeye": "^0.4.8",
58+
"n3": "^1.17.1"
59+
},
60+
"devDependencies": {
61+
"@solid/community-server": "7.0.3",
62+
"@types/node": "^20.11.16",
63+
"ts-node": "^10.9.1",
64+
"typescript": "^5.3.3"
65+
}
66+
}

0 commit comments

Comments
 (0)