Skip to content

Commit 7111713

Browse files
authored
Merge pull request #1633 from solid/check-write-on-container-for-delete
Check write on container for delete
2 parents ebbc6d7 + 63d46a2 commit 7111713

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

lib/acl-checker.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,27 @@ class ACLChecker {
8787
}
8888
let accessDenied = aclCheck.accessDenied(acl.graph, resource, directory, aclFile, agent, modes, agentOrigin, trustedOrigins, originTrustedModes)
8989

90+
function accessDeniedForAccessTo (mode) {
91+
const accessDeniedAccessTo = aclCheck.accessDenied(acl.graph, directory, null, aclFile, agent, [ACL(mode)], agentOrigin, trustedOrigins, originTrustedModes)
92+
const accessResult = !accessDenied && !accessDeniedAccessTo
93+
accessDenied = accessResult ? false : accessDenied || accessDeniedAccessTo
94+
// debugCache('accessDenied result ' + accessDenied)
95+
}
9096
// For create and update HTTP methods
9197
if ((method === 'PUT' || method === 'PATCH' || method === 'COPY') && directory) {
9298
// if resource and acl have same parent container,
9399
// and resource does not exist, then accessTo Append from parent is required
94100
if (directory.value === dirname(aclFile.value) + '/' && !resourceExists) {
95-
const accessDeniedAccessTo = aclCheck.accessDenied(acl.graph, directory, null, aclFile, agent, [ACL('Append')], agentOrigin, trustedOrigins, originTrustedModes)
96-
const accessResult = !accessDenied && !accessDeniedAccessTo
97-
accessDenied = accessResult ? false : accessDenied || accessDeniedAccessTo
98-
// debugCache('accessDenied result ' + accessDenied)
101+
accessDeniedForAccessTo('Append')
102+
}
103+
}
104+
105+
// For delete HTTP method
106+
if ((method === 'DELETE') && directory) {
107+
// if resource and acl have same parent container,
108+
// then accessTo Write from parent is required
109+
if (directory.value === dirname(aclFile.value) + '/') {
110+
accessDeniedForAccessTo('Write')
99111
}
100112
}
101113
if (accessDenied && user) {

test/surface/run-solid-test-suite.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ waitForNss server
4949
runTests webid-provider-tests v2.0.3
5050
runTests solid-crud-tests nss-skips
5151
waitForNss thirdparty
52-
runTests web-access-control-tests v5.1.0
52+
runTests web-access-control-tests v6.0.0
5353
teardown
5454

5555
# To debug, e.g. running web-access-control-tests jest interactively,

0 commit comments

Comments
 (0)