Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
751 changes: 279 additions & 472 deletions lib/acl.js

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions lib/ldp-middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ function LdpMiddleware (corsSettings) {
router.use('/*', login.loginHandler);

//ACL handlers
router.get("/*", acl.allowReadHandler);
router.post("/*", acl.allowAppendThenWriteHandler);
router.patch("/*", acl.allowAppendThenWriteHandler);
router.put("/*", acl.allowAppendThenWriteHandler);
router.delete("/*", acl.allowWriteHandler);
router.get("/*", acl.allow('Read'));
router.head("/*", acl.allow('Read'));
router.post("/*", acl.allow('Append'));
router.patch("/*", acl.allow('Append'));
router.put("/*", acl.allow('Append'));
router.delete("/*", acl.allow('Write'));

// Convert json-ld and nquads to turtle
router.use('/*', parse.parseHandler);
Expand Down
4 changes: 2 additions & 2 deletions lib/ldp.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,15 @@ LDP.prototype.put = function (filePath, contents, callback) {
mkdirp(path.dirname(filePath), function (err) {
if (err) {
debug.handlers("PUT -- Error creating directory: " + err);
return callback(new HTTPError({
return callback(new HttpError({
status: err.code === 'ENOENT' ? 404 : 500,
message: err.message
}));
}
return fs.writeFile(filePath, contents, function() {
if (err) {
debug.handlers("PUT -- Error writing file: " + err);
return callback(new HTTPError({
return callback(new HttpError({
status: err.code === 'ENOENT' ? 404 : 500,
message: err.message
}));
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@
"node-uuid": "^1.4.3",
"nomnom": "^1.8.1",
"raw-body": "^2.1.2",
"rdflib": "^0.2.9",
"rdflib": "^0.2.10",
"redis": "^0.12.1",
"request": "^2.58.0",
"response-time": "^2.3.1",
"solid-acl": "^1.0.1",
"solid-ws": "^0.2.0",
"string": "^3.3.0",
"webid": "^0.3.1"
Expand Down
818 changes: 188 additions & 630 deletions test/acl.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions test/resources/acl/append-acl/abc.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<g> <h> <i> .
8 changes: 8 additions & 0 deletions test/resources/acl/append-acl/abc.ttl.acl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<#Owner>
<http://www.w3.org/ns/auth/acl#accessTo> <./abc.ttl>;
<http://www.w3.org/ns/auth/acl#agent> <https://user1.databox.me/profile/card#me>;
<http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read>, <http://www.w3.org/ns/auth/acl#Write>, <http://www.w3.org/ns/auth/acl#Control> .
<#AppendOnly>
<http://www.w3.org/ns/auth/acl#accessTo> <./abc.ttl>;
<http://www.w3.org/ns/auth/acl#agentClass> <http://xmlns.com/foaf/0.1/Agent>;
<http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Append> .
1 change: 1 addition & 0 deletions test/resources/acl/append-acl/abc2.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<d> <e> <f> .
8 changes: 8 additions & 0 deletions test/resources/acl/append-acl/abc2.ttl.acl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<#Owner>
<http://www.w3.org/ns/auth/acl#accessTo> <./abc2.ttl>;
<http://www.w3.org/ns/auth/acl#agent> <https://user1.databox.me/profile/card#me>;
<http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read>, <http://www.w3.org/ns/auth/acl#Write>, <http://www.w3.org/ns/auth/acl#Control> .
<#Restricted>
<http://www.w3.org/ns/auth/acl#accessTo> <./abc2.ttl>;
<http://www.w3.org/ns/auth/acl#agent> <https://user2.databox.me/profile/card#me>;
<http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read>, <http://www.w3.org/ns/auth/acl#Write>.
Empty file.
1 change: 1 addition & 0 deletions test/resources/acl/no-acl/test-file.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test-file.html
4 changes: 4 additions & 0 deletions test/resources/acl/origin/.acl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<#0>
<http://www.w3.org/ns/auth/acl#defaultForNew> <./> ;
<http://www.w3.org/ns/auth/acl#agent> <https://user1.databox.me/profile/card#me> ;
<http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Write>, <http://www.w3.org/ns/auth/acl#Control>.
10 changes: 10 additions & 0 deletions test/resources/acl/read-acl/.acl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<#Owner>
a <http://www.w3.org/ns/auth/acl#Authorization> ;
<http://www.w3.org/ns/auth/acl#accessTo> <./>;
<http://www.w3.org/ns/auth/acl#agent> <https://user1.databox.me/profile/card#me>;
<http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read>, <http://www.w3.org/ns/auth/acl#Write>, <http://www.w3.org/ns/auth/acl#Control> .
<#Public>
a <http://www.w3.org/ns/auth/acl#Authorization> ;
<http://www.w3.org/ns/auth/acl#accessTo> <./>;
<http://www.w3.org/ns/auth/acl#agentClass> <http://xmlns.com/foaf/0.1/Agent>;
<http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read> .
4 changes: 4 additions & 0 deletions test/resources/acl/write-acl/.acl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<#0>
<http://www.w3.org/ns/auth/acl#defaultForNew> <./> ;
<http://www.w3.org/ns/auth/acl#agent> <https://user1.databox.me/profile/card#me> ;
<http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Write>, <http://www.w3.org/ns/auth/acl#Control>.
Empty file.