Skip to content

Commit

Permalink
Merge pull request #1419 from solid/postAclFix
Browse files Browse the repository at this point in the history
Merge approved in a private repo
  • Loading branch information
jaxoncreed authored Apr 12, 2020
2 parents 23a92eb + 16c18ea commit 818a0cd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
9 changes: 8 additions & 1 deletion lib/acl-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class ACLChecker {
this.aclCached = {}
this.messagesCached = {}
this.requests = {}
this.slug = options.slug
}

// Returns a fulfilled promise when the user can access the resource
Expand Down Expand Up @@ -53,6 +54,11 @@ class ACLChecker {
mode = 'Control'
resource = rdf.sym(this.resource.substring(0, this.resource.length - this.suffix.length))
}
// If the slug is an acl, reject
if (this.isAcl(this.slug)) {
this.aclCached[cacheKey] = Promise.resolve(false)
return this.aclCached[cacheKey]
}
const directory = acl.isContainer ? rdf.sym(ACLChecker.getDirectory(acl.acl)) : null
const aclFile = rdf.sym(acl.acl)
const agent = user ? rdf.sym(user) : null
Expand Down Expand Up @@ -167,7 +173,8 @@ class ACLChecker {
},
suffix: ldp.suffixAcl,
strictOrigin: ldp.strictOrigin,
trustedOrigins
trustedOrigins,
slug: decodeURIComponent(req.headers['slug'])
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "solid-server",
"description": "Solid server on top of the file-system",
"version": "5.2.3",
"version": "5.2.4",
"author": {
"name": "Tim Berners-Lee",
"email": "[email protected]"
Expand Down
10 changes: 10 additions & 0 deletions test/integration/acl-oidc-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,16 @@ describe('ACL with WebID+OIDC over HTTP', function () {
done()
})
})
it('user2 should not be able able to post an acl file', function (done) {
var options = createOptions('/append-acl/abc.ttl.acl', 'user2', 'text/turtle')
options.body = '<a> <b> <c> .\n'
request.put(options, function (error, response, body) {
assert.equal(error, null)
assert.equal(response.statusCode, 403)
assert.equal(response.statusMessage, 'User Unauthorized')
done()
})
})
it('user2 should not be able to access test file', function (done) {
var options = createOptions('/append-acl/abc.ttl', 'user2', 'text/turtle')
request.head(options, function (error, response, body) {
Expand Down

0 comments on commit 818a0cd

Please sign in to comment.