Skip to content

Commit 17c60c9

Browse files
committed
feat: Add option to set UMA Auth Server URL on Solid Server initialization
1 parent ccf0a2f commit 17c60c9

4 files changed

Lines changed: 52 additions & 3 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"build": "yarn workspaces foreach --include 'packages/*' -A -pi -j unlimited -t run build",
5757
"test": "yarn workspaces foreach --include 'packages/*' -A -pi -j unlimited run test",
5858
"start": "yarn workspaces foreach --include 'packages/*' -A -pi -j unlimited run start",
59+
"start:demo": "yarn workspaces foreach --include 'packages/*' -A -pi -j unlimited run demo",
5960
"script:public": "yarn exec ts-node ./scripts/test-public.ts",
6061
"script:private": "yarn exec ts-node ./scripts/test-private.ts",
6162
"script:registration": "yarn exec ts-node ./scripts/test-registration.ts",

packages/css/config/uma/default.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@
7373
"umaPatStore": {
7474
"@id": "urn:solid-server:default:UmaPatStore",
7575
"@type": "MemoryMapStorage"
76+
},
77+
"umaServerURL": {
78+
"@id": "urn:solid-server:uma:variable:AuthorizationServer"
7679
}
7780
},
7881
{
@@ -98,6 +101,41 @@
98101
"@id": "urn:solid-server:default:ResourceRegistrar"
99102
}
100103
]
104+
},
105+
{
106+
"@id": "urn:solid-server-app-setup:default:CliExtractor",
107+
"@type": "YargsCliExtractor",
108+
"parameters": [
109+
{
110+
"@type": "YargsParameter",
111+
"name": "authServer",
112+
"options": {
113+
"alias": "a",
114+
"requiresArg": true,
115+
"type": "string",
116+
"describe": "The URL of the UMA Authorization Server."
117+
}
118+
}
119+
]
120+
}, {
121+
"comment": "Converts an input key/value object into an object mapping values to Components.js variables",
122+
"@id": "urn:solid-server-app-setup:default:ShorthandResolver",
123+
"@type": "CombinedShorthandResolver",
124+
"resolvers": [
125+
{
126+
"CombinedShorthandResolver:_resolvers_key": "urn:solid-server:uma:variable:AuthorizationServer",
127+
"CombinedShorthandResolver:_resolvers_value": {
128+
"@type": "KeyExtractor",
129+
"key": "authServer",
130+
"defaultValue": "http://localhost:4000"
131+
}
132+
}
133+
]
134+
},
135+
{
136+
"comment": "URL of the UMA Authorization Server.",
137+
"@id": "urn:solid-server:uma:variable:AuthorizationServer",
138+
"@type": "Variable"
101139
}
102140
]
103141
}

packages/css/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@
6060
"build:ts": "yarn run -T tsc",
6161
"build:components": "yarn run -T componentsjs-generator -r uma-css -s src/ -c dist/components -i .componentsignore --lenient",
6262
"test": "yarn run -T jest --coverage",
63-
"start": "yarn run community-solid-server -m . -c ./config/default.json --seedConfig ./config/seed.json",
63+
"start:unseeded": "yarn run community-solid-server -m . -c ./config/default.json -a http://localhost:4000/",
64+
"start": "yarn run community-solid-server -m . -c ./config/default.json --seedConfig ./config/seed.json -a http://localhost:4000/",
6465
"demo": "yarn run demo:setup && yarn run demo:start",
6566
"demo:setup": "yarn run -T shx rm -rf ./tmp && yarn run -T shx cp -R ../../demo/data ./tmp",
66-
"demo:start": "yarn run community-solid-server -m . -c ./config/demo.json -f ./tmp"
67+
"demo:start": "yarn run community-solid-server -m . -c ./config/demo.json -f ./tmp -a http://localhost:4000/"
6768
},
6869
"dependencies": {
6970
"@solid/community-server": "^7.0.2",

packages/css/src/util/OwnerUtil.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export class OwnerUtil {
1919
protected accountStore: AccountStore,
2020
protected storageStrategy: StorageLocationStrategy,
2121
protected umaPatStore: KeyValueStorage<string, { issuer: string, pat: string }>,
22+
protected umaServerURL: string,
2223
) {}
2324

2425
/**
@@ -74,7 +75,15 @@ export class OwnerUtil {
7475
}
7576

7677
public async findIssuer(webid: string): Promise<string | undefined> {
77-
return 'http://localhost:4000/uma';
78+
if (!this.umaServerURL) {
79+
this.logger.warn(`No UMA Authorization Server variable set. Falling back on http://localhost:4000/`)
80+
return 'http://localhost:4000/uma';
81+
}
82+
this.logger.verbose(`Using UMA Authorization Server at ${this.umaServerURL} for WebID ${webid}.`)
83+
return this.umaServerURL.endsWith('/') ? this.umaServerURL + 'uma' : this.umaServerURL + '/uma'
84+
85+
// Dunno if it makes sense to code this as retrieving it from the WebID at this point?
86+
// I think we are far off from dynamically attaching multiple auth servers to a single solid server.
7887

7988
// TODO: softcode
8089

0 commit comments

Comments
 (0)