Skip to content

Commit a90d9be

Browse files
feat: sign traffic between RS and AS (#31)
Signed-off-by: Wouter Termont <wouter.termont@ugent.be> Co-authored-by: Wout Slabbinck <wout.slabbinck@ugent.be>
1 parent beb9c14 commit a90d9be

Some content is hidden

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

46 files changed

+1264
-959
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This repository contains SolidLab research artefacts on use of UMA in the Solid
1717

1818
In order to run this project you need to perform the following steps.
1919

20-
1. Ensure that you are using Node.js 18.18 or higher, e.g. by running `nvm use`.
20+
1. Ensure that you are using Node.js 20 or higher, e.g. by running `nvm use`. (see [.nvmrc](./.nvmrc))
2121
1. Enable Node.js Corepack with `corepack enable`.
2222
1. Run `yarn install` in the project root (this will automatically call `yarn build:all`).
2323
1. Run `yarn start:all`.

packages/css/config/ldp/authentication/uma.json

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,6 @@
3232
}
3333
]
3434
}
35-
},
36-
{
37-
"comment": "Returns the UMA ticket in case of an unauthorized request.",
38-
"@id": "urn:solid-server:default:UmaClient",
39-
"@type": "UmaClientImpl",
40-
"UmaClientImpl:_args_asUrl": "http://localhost:4000/uma",
41-
"UmaClientImpl:_args_credentials_ecAlgorithm": "ES256",
42-
"UmaClientImpl:_args_credentials_ecPrivateKey": "-----BEGIN PRIVATE KEY-----MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg/cteLEDr0AH+7mA3lvCtf2pY32NMVpy2yWCk8LbfJ+WhRANCAAQYmTM7fikydPHi7GhMPT528HiBVpez1f6qSC7NQI1P1nNtn+idNmu9AMtUB0f75zuxL++Z+s24AJR42Euv1pgU-----END PRIVATE KEY----",
43-
"UmaClientImpl:_args_baseUrl": {
44-
"@id": "urn:solid-server:default:variable:baseUrl"
45-
},
46-
"UmaClientImpl:_args_maxTokenAge": 600
4735
}
4836
]
49-
}
37+
}

packages/css/config/uma/default.json

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,50 @@
44
"https://linkedsoftwaredependencies.org/bundles/npm/@solidlab/uma-css/^0.0.0/components/context.jsonld"
55
],
66
"@graph": [
7+
{
8+
"@id": "urn:solid-server:default:ServerConfigurator",
9+
"@type": "ParallelHandler",
10+
"handlers": [
11+
{
12+
"@id": "urn:solid-server:default:StatusDependantServerConfigurator",
13+
"@type": "StatusDependantServerConfigurator",
14+
"dependants": [
15+
{ "@id": "urn:solid-server:default:Fetcher" }
16+
],
17+
"statusMap": [
18+
{
19+
"StatusDependantServerConfigurator:_statusMap_key": "listening",
20+
"StatusDependantServerConfigurator:_statusMap_value": true
21+
},
22+
{
23+
"StatusDependantServerConfigurator:_statusMap_key": "close",
24+
"StatusDependantServerConfigurator:_statusMap_value": false
25+
},
26+
{
27+
"StatusDependantServerConfigurator:_statusMap_key": "error",
28+
"StatusDependantServerConfigurator:_statusMap_value": false
29+
}
30+
]
31+
}
32+
]
33+
},
734
{
835
"comment": "Returns the UMA ticket in case of an unauthorized request.",
936
"@id": "urn:solid-server:default:UmaClient",
10-
"@type": "UmaClientImpl",
11-
"UmaClientImpl:pat": "MYPAT",
12-
"UmaClientImpl:_options_maxTokenAge": 600
37+
"@type": "UmaClient",
38+
"baseUrl": {
39+
"@id": "urn:solid-server:default:variable:baseUrl"
40+
},
41+
"keyGen": {
42+
"@id": "urn:solid-server:default:JwkGenerator"
43+
},
44+
"fetcher": {
45+
"@id": "urn:solid-server:default:Fetcher",
46+
"@type": "PausableFetcher",
47+
"fetcher": {
48+
"@type": "BaseFetcher"
49+
}
50+
}
1351
},
1452
{
1553
"@id": "urn:solid-server:default:OwnerUtil",
@@ -35,12 +73,15 @@
3573
"store": {
3674
"@id": "urn:solid-server:default:ResourceStore"
3775
},
38-
"ownerUtil": {
39-
"@id": "urn:solid-server:default:OwnerUtil"
40-
},
4176
"umaIdStore": {
4277
"@id": "urn:solid-server:default:UmaIdStore",
4378
"@type": "MemoryMapStorage"
79+
},
80+
"ownerUtil": {
81+
"@id": "urn:solid-server:default:OwnerUtil"
82+
},
83+
"umaClient": {
84+
"@id": "urn:solid-server:default:UmaClient"
4485
}
4586
},
4687
{

packages/css/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"@solidlab/uma": "workspace:^",
6868
"componentsjs": "^5.4.2",
6969
"cross-fetch": "^4.0.0",
70+
"http-message-signatures": "^1.0.4",
7071
"jose": "^5.2.2",
7172
"n3": "^1.17.2"
7273
},

packages/css/src/authentication/UmaTokenExtractor.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { CredentialsExtractor, getLoggerFor, HttpRequest,
22
NotImplementedHttpError, BadRequestHttpError, Credentials, TargetExtractor } from '@solid/community-server';
33
import { UmaClaims, UmaClient } from '../uma/UmaClient';
44
import { OwnerUtil } from '../util/OwnerUtil';
5-
import { decodeJwt } from 'jose';
65

76
export type UmaCredentials = Credentials & { uma: { rpt: UmaClaims } };
87

@@ -40,8 +39,10 @@ export class UmaTokenExtractor extends CredentialsExtractor {
4039
*/
4140
public async handle(request: HttpRequest): Promise<UmaCredentials> {
4241
this.logger.info('Extracting token from ' + request.headers.authorization);
42+
4343
const token = request.headers.authorization?.replace(/^Bearer/, '')?.trimStart();
4444
if (!token) throw new BadRequestHttpError('Found empty Bearer token.');
45+
4546
try {
4647
const target = await this.targetExtractor.handle({ request });
4748
const owners = await this.ownerUtil.findOwners(target);
@@ -70,7 +71,7 @@ export class UmaTokenExtractor extends CredentialsExtractor {
7071
private async tryIntrospection(token: string, owner: string): Promise<UmaClaims> {
7172
const issuer = await this.ownerUtil.findIssuer(owner);
7273
if (!issuer) return Promise.reject();
73-
return this.client.verifyOpaqueToken(token, issuer, owner)
74+
return this.client.verifyOpaqueToken(token, issuer)
7475
}
7576

7677
}

packages/css/src/authorization/UmaAuthorizer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class UmaAuthorizer extends Authorizer {
6868
if (!issuer) throw new Error(`No UMA authorization server found for ${owner}.`);
6969

7070
try {
71-
const ticket = await this.umaClient.fetchTicket(requestedModes, owner, issuer);
71+
const ticket = await this.umaClient.fetchTicket(requestedModes, issuer);
7272
return ticket ? `UMA realm="solid", as_uri="${issuer}", ticket="${ticket}"` : undefined;
7373
} catch (e) {
7474
this.logger.error(`Error while requesting UMA header: ${(e as Error).message}`);

packages/uma/src/secrets/InMemoryJwksKeyHolder.ts renamed to packages/css/src/identity/configuration/InMemoryJwksKeyHolder.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import {exportJWK, generateKeyPair, JSONWebKeySet, JWK, KeyLike} from 'jose';
2-
import {JwksKeyHolder} from './JwksKeyHolder';
3-
import {v4} from 'uuid';
4-
import {Logger} from '../util/logging/Logger';
5-
import {getLoggerFor} from '../util/logging/LoggerUtils';
1+
import { exportJWK, generateKeyPair, JSONWebKeySet, JWK, KeyLike } from 'jose';
2+
import { JwksKeyHolder } from './JwksKeyHolder';
3+
import { v4 } from 'uuid';
4+
import { getLoggerFor } from '@solid/community-server';
65

76
const SUPPORTED_ALGORITHMS = new Set(['ES256', 'ES384', 'ES512', 'RS256', 'RS384', 'RS512']);
87

@@ -15,7 +14,7 @@ export interface KeyPair {
1514
* In-memory implementation of a JWKS Key Holder.
1615
*/
1716
export class InMemoryJwksKeyHolder extends JwksKeyHolder {
18-
protected readonly logger: Logger = getLoggerFor(this);
17+
protected readonly logger = getLoggerFor(this);
1918
private readonly keys: Map<string, KeyPair>;
2019
private currentKid: undefined | string;
2120

packages/uma/src/secrets/JwksKeyHolder.ts renamed to packages/css/src/identity/configuration/JwksKeyHolder.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import * as jose from 'jose';
32

43
/**

packages/css/src/index.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ export * from './authorization/UmaPermissionReader';
55

66
export * from './http/output/metadata/UmaTicketMetadataWriter';
77

8+
// export * from './identity/configuration/JwksKeyHolder';
9+
// export * from './identity/configuration/InMemoryJwksKeyHolder';
10+
811
export * from './identity/interaction/account/util/AccountStore';
912
export * from './identity/interaction/account/util/BaseAccountStore';
1013
export * from './identity/interaction/account/util/LoginStorage';
@@ -19,8 +22,11 @@ export * from './storage/keyvalue/IndexedStorage';
1922

2023
export * from './uma/ResourceRegistrar';
2124
export * from './uma/UmaClient';
22-
export * from './uma/UmaClientImpl';
2325

2426
export * from './util/OwnerUtil';
25-
export * from './util/StringGuard';
26-
export * from './util/Vocabularies';
27+
28+
export * from './util/fetch/Fetcher';
29+
export * from './util/fetch/BaseFetcher';
30+
export * from './util/fetch/PausableFetcher';
31+
export * from './util/fetch/StatusDependant';
32+
export * from './util/fetch/StatusDependantServerConfigurator';

packages/css/src/server/middleware/JwksHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ export class JwksHandler extends HttpHandler {
3636
return;
3737
}
3838

39-
response.end(JSON.stringify({ keys: [ key ] }));
39+
response.end(JSON.stringify({ keys: [ Object.assign(key, { kid: 'TODO' }) ] }));
4040
}
4141
}

0 commit comments

Comments
 (0)