Skip to content

Commit 818a0cd

Browse files
authored
Merge pull request #1419 from solid/postAclFix
Merge approved in a private repo
2 parents 23a92eb + 16c18ea commit 818a0cd

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

lib/acl-checker.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class ACLChecker {
2626
this.aclCached = {}
2727
this.messagesCached = {}
2828
this.requests = {}
29+
this.slug = options.slug
2930
}
3031

3132
// Returns a fulfilled promise when the user can access the resource
@@ -53,6 +54,11 @@ class ACLChecker {
5354
mode = 'Control'
5455
resource = rdf.sym(this.resource.substring(0, this.resource.length - this.suffix.length))
5556
}
57+
// If the slug is an acl, reject
58+
if (this.isAcl(this.slug)) {
59+
this.aclCached[cacheKey] = Promise.resolve(false)
60+
return this.aclCached[cacheKey]
61+
}
5662
const directory = acl.isContainer ? rdf.sym(ACLChecker.getDirectory(acl.acl)) : null
5763
const aclFile = rdf.sym(acl.acl)
5864
const agent = user ? rdf.sym(user) : null
@@ -167,7 +173,8 @@ class ACLChecker {
167173
},
168174
suffix: ldp.suffixAcl,
169175
strictOrigin: ldp.strictOrigin,
170-
trustedOrigins
176+
trustedOrigins,
177+
slug: decodeURIComponent(req.headers['slug'])
171178
})
172179
}
173180
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "solid-server",
33
"description": "Solid server on top of the file-system",
4-
"version": "5.2.3",
4+
"version": "5.2.4",
55
"author": {
66
"name": "Tim Berners-Lee",
77
"email": "[email protected]"

test/integration/acl-oidc-test.js

+10
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,16 @@ describe('ACL with WebID+OIDC over HTTP', function () {
545545
done()
546546
})
547547
})
548+
it('user2 should not be able able to post an acl file', function (done) {
549+
var options = createOptions('/append-acl/abc.ttl.acl', 'user2', 'text/turtle')
550+
options.body = '<a> <b> <c> .\n'
551+
request.put(options, function (error, response, body) {
552+
assert.equal(error, null)
553+
assert.equal(response.statusCode, 403)
554+
assert.equal(response.statusMessage, 'User Unauthorized')
555+
done()
556+
})
557+
})
548558
it('user2 should not be able to access test file', function (done) {
549559
var options = createOptions('/append-acl/abc.ttl', 'user2', 'text/turtle')
550560
request.head(options, function (error, response, body) {

0 commit comments

Comments
 (0)