Skip to content

Commit 3d9b2bc

Browse files
authored
Merge pull request #1144 from solid/redo-1122
Redo #1122
2 parents dca8d65 + a5d3ad5 commit 3d9b2bc

File tree

8 files changed

+164
-49
lines changed

8 files changed

+164
-49
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,17 @@
2121
- The browser-reported `Origin` header will now be checked by
2222
default, and the ACL system can be used to restrict access
2323
to applications for added security.
24+
- Users can add `trustedApp` entries to their profile using a new databrowser pane.
25+
You will see an 'A' icon added while you view a Person's profile URL
26+
with the data browser (might have to hit refresh in your browser and make sure you
27+
are viewing a WebId URL like https://localhost:8443/profile/card#me).
2428
- Logging is now verbose by default so the `-v` option has been
2529
removed and a `--quiet` option has been added to mute the log.
2630
- To be bug compliant with 4.x releases, if a rule for public readable
2731
root / does not exist, it will check in /index.html.acl (see issue #1063)
2832
- Command line options are now kebab-cased rather than camelCased,
2933
config options may be both.
34+
- Resource with no extension now have '$.ttl' appended in the filename (see upgrades notes below).
3035
- Many smaller fixes.
3136

3237
#### 5.0.0 Upgrade Notes

lib/acl-checker.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,17 @@ class ACLChecker {
5757
const modes = [ACL(mode)]
5858
const agentOrigin = this.agentOrigin
5959
const trustedOrigins = this.trustedOrigins
60-
const accessDenied = aclCheck.accessDenied(acl.graph, resource, directory, aclFile, agent, modes, agentOrigin, trustedOrigins)
61-
60+
let originTrustedModes = []
61+
try {
62+
this.fetch(aclFile.doc().value)
63+
originTrustedModes = await aclCheck.getTrustedModesForOrigin(acl.graph, resource, directory, aclFile, agentOrigin, (uriNode) => {
64+
return this.fetch(uriNode.doc().value, acl.graph)
65+
})
66+
} catch (e) {
67+
// FIXME: https://github.com/solid/acl-check/issues/23
68+
// console.error(e.message)
69+
}
70+
const accessDenied = aclCheck.accessDenied(acl.graph, resource, directory, aclFile, agent, modes, agentOrigin, trustedOrigins, originTrustedModes)
6271
if (accessDenied && user) {
6372
this.messagesCached[cacheKey].push(HTTPError(403, accessDenied))
6473
} else if (accessDenied) {

package-lock.json

Lines changed: 50 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"bugs": "https://github.com/solid/node-solid-server/issues",
5757
"dependencies": {
5858
"@solid/oidc-auth-manager": "^0.17.1",
59-
"@solid/acl-check": "^0.1.3",
59+
"@solid/acl-check": "^0.2.0",
6060
"body-parser": "^1.18.3",
6161
"bootstrap": "^3.3.7",
6262
"busboy": "^0.2.12",
@@ -82,7 +82,7 @@
8282
"ip-range-check": "0.0.2",
8383
"is-ip": "^2.0.0",
8484
"li": "^1.0.1",
85-
"mashlib": "^0.7.15",
85+
"mashlib": "^0.7.18",
8686
"mime-types": "^2.1.11",
8787
"negotiator": "^0.6.0",
8888
"node-fetch": "^2.1.2",

test/integration/authentication-oidc-test.js

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ chai.use(require('dirty-chai'))
2020
// In this test we always assume that we are Alice
2121

2222
describe('Authentication API (OIDC)', () => {
23-
let alice, bob
23+
let alice, bob // eslint-disable-line no-unused-vars
2424

2525
let aliceServerUri = 'https://localhost:7000'
2626
let aliceWebId = 'https://localhost:7000/profile/card#me'
@@ -35,6 +35,8 @@ describe('Authentication API (OIDC)', () => {
3535
let bobDbPath = path.join(__dirname,
3636
'../resources/accounts-scenario/bob/db')
3737

38+
const trustedAppUri = 'https://trusted.app'
39+
3840
const serverConfig = {
3941
sslKey: path.join(__dirname, '../keys/key.pem'),
4042
sslCert: path.join(__dirname, '../keys/cert.pem'),
@@ -437,6 +439,48 @@ describe('Authentication API (OIDC)', () => {
437439
expect(response).to.have.property('status', 401)
438440
})
439441
})
442+
443+
describe('with trusted app and no cookie', () => {
444+
before(done => {
445+
alice.get('/private-for-alice.txt')
446+
.set('Origin', trustedAppUri)
447+
.end((err, res) => {
448+
response = res
449+
done(err)
450+
})
451+
})
452+
453+
it('should return a 401', () => expect(response).to.have.property('status', 401))
454+
})
455+
456+
describe('with trusted app and malicious cookie', () => {
457+
before(done => {
458+
var malcookie = cookie.replace(/connect\.sid=(\S+)/, 'connect.sid=l33th4x0rzp0wn4g3;')
459+
alice.get('/private-for-alice.txt')
460+
.set('Cookie', malcookie)
461+
.set('Origin', trustedAppUri)
462+
.end((err, res) => {
463+
response = res
464+
done(err)
465+
})
466+
})
467+
468+
it('should return a 401', () => expect(response).to.have.property('status', 401))
469+
})
470+
471+
describe('with trusted app and correct cookie', () => {
472+
before(done => {
473+
alice.get('/private-for-alice.txt')
474+
.set('Cookie', cookie)
475+
.set('Origin', trustedAppUri)
476+
.end((err, res) => {
477+
response = res
478+
done(err)
479+
})
480+
})
481+
482+
it('should return a 200', () => expect(response).to.have.property('status', 200))
483+
})
440484
})
441485
})
442486

test/integration/authentication-oidc-with-strict-origins-turned-off-test.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ describe('Authentication API (OIDC) - With strict origins turned off', () => {
3535
const bobServerUri = `https://localhost:${bobServerPort}`
3636
let bobDbPath = path.join(__dirname, '../resources/accounts-strict-origin-off/bob/db')
3737

38+
const trustedAppUri = 'https://trusted.app'
39+
3840
const serverConfig = {
3941
sslKey: path.join(__dirname, '../keys/key.pem'),
4042
sslCert: path.join(__dirname, '../keys/cert.pem'),
@@ -194,6 +196,18 @@ describe('Authentication API (OIDC) - With strict origins turned off', () => {
194196
})
195197
})
196198

199+
it('should return a 401', () => expect(response).to.have.property('status', 401))
200+
})
201+
describe('and trusted app', () => {
202+
before(done => {
203+
alice.get('/private-for-alice.txt')
204+
.set('Origin', trustedAppUri)
205+
.end((err, res) => {
206+
response = res
207+
done(err)
208+
})
209+
})
210+
197211
it('should return a 401', () => expect(response).to.have.property('status', 401))
198212
})
199213
})
@@ -251,6 +265,21 @@ describe('Authentication API (OIDC) - With strict origins turned off', () => {
251265
// Even if origin checking is disabled, then this should return a 401 because cookies should not be trusted cross-origin
252266
it('should return a 401', () => expect(response).to.have.property('status', 401))
253267
})
268+
269+
describe('and trusted app', () => {
270+
// Trusted apps are not supported when strictOrigin check is turned off
271+
before(done => {
272+
alice.get('/private-for-alice.txt')
273+
.set('Cookie', cookie)
274+
.set('Origin', trustedAppUri)
275+
.end((err, res) => {
276+
response = res
277+
done(err)
278+
})
279+
})
280+
281+
it('should return a 401', () => expect(response).to.have.property('status', 401))
282+
})
254283
})
255284

256285
describe('with malicious cookie', () => {
@@ -310,6 +339,20 @@ describe('Authentication API (OIDC) - With strict origins turned off', () => {
310339

311340
it('should return a 401', () => expect(response).to.have.property('status', 401))
312341
})
342+
343+
describe('and trusted app', () => {
344+
before(done => {
345+
alice.get('/private-for-alice.txt')
346+
.set('Cookie', malcookie)
347+
.set('Origin', trustedAppUri)
348+
.end((err, res) => {
349+
response = res
350+
done(err)
351+
})
352+
})
353+
354+
it('should return a 401', () => expect(response).to.have.property('status', 401))
355+
})
313356
})
314357
})
315358
})
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@prefix acl: <http://www.w3.org/ns/auth/acl#>.
2+
3+
<#me> acl:trustedApp [ acl:origin <https://trusted.app>;
4+
acl:mode acl:Read, acl:Write, acl:Append, acl:Control].

0 commit comments

Comments
 (0)