Skip to content

Commit 3d809ec

Browse files
author
Andrei
committed
Merge pull request nodeSolidServer#147 from nicola/solid-acl
New ACL
2 parents 3c70036 + fecd475 commit 3d809ec

15 files changed

Lines changed: 514 additions & 1110 deletions

File tree

lib/acl.js

Lines changed: 279 additions & 472 deletions
Large diffs are not rendered by default.

lib/ldp-middleware.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@ function LdpMiddleware (corsSettings) {
3737
router.use('/*', login.loginHandler);
3838

3939
//ACL handlers
40-
router.get("/*", acl.allowReadHandler);
41-
router.post("/*", acl.allowAppendThenWriteHandler);
42-
router.patch("/*", acl.allowAppendThenWriteHandler);
43-
router.put("/*", acl.allowAppendThenWriteHandler);
44-
router.delete("/*", acl.allowWriteHandler);
40+
router.get("/*", acl.allow('Read'));
41+
router.head("/*", acl.allow('Read'));
42+
router.post("/*", acl.allow('Append'));
43+
router.patch("/*", acl.allow('Append'));
44+
router.put("/*", acl.allow('Append'));
45+
router.delete("/*", acl.allow('Write'));
4546

4647
// Convert json-ld and nquads to turtle
4748
router.use('/*', parse.parseHandler);

lib/ldp.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,15 +328,15 @@ LDP.prototype.put = function (filePath, contents, callback) {
328328
mkdirp(path.dirname(filePath), function (err) {
329329
if (err) {
330330
debug.handlers("PUT -- Error creating directory: " + err);
331-
return callback(new HTTPError({
331+
return callback(new HttpError({
332332
status: err.code === 'ENOENT' ? 404 : 500,
333333
message: err.message
334334
}));
335335
}
336336
return fs.writeFile(filePath, contents, function() {
337337
if (err) {
338338
debug.handlers("PUT -- Error writing file: " + err);
339-
return callback(new HTTPError({
339+
return callback(new HttpError({
340340
status: err.code === 'ENOENT' ? 404 : 500,
341341
message: err.message
342342
}));

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@
4242
"node-uuid": "^1.4.3",
4343
"nomnom": "^1.8.1",
4444
"raw-body": "^2.1.2",
45-
"rdflib": "^0.2.9",
45+
"rdflib": "^0.2.10",
4646
"redis": "^0.12.1",
4747
"request": "^2.58.0",
4848
"response-time": "^2.3.1",
49+
"solid-acl": "^1.0.1",
4950
"solid-ws": "^0.2.0",
5051
"string": "^3.3.0",
5152
"webid": "^0.3.1"

test/acl.js

Lines changed: 188 additions & 630 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<g> <h> <i> .
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<#Owner>
2+
<http://www.w3.org/ns/auth/acl#accessTo> <./abc.ttl>;
3+
<http://www.w3.org/ns/auth/acl#agent> <https://user1.databox.me/profile/card#me>;
4+
<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> .
5+
<#AppendOnly>
6+
<http://www.w3.org/ns/auth/acl#accessTo> <./abc.ttl>;
7+
<http://www.w3.org/ns/auth/acl#agentClass> <http://xmlns.com/foaf/0.1/Agent>;
8+
<http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Append> .
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<d> <e> <f> .
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<#Owner>
2+
<http://www.w3.org/ns/auth/acl#accessTo> <./abc2.ttl>;
3+
<http://www.w3.org/ns/auth/acl#agent> <https://user1.databox.me/profile/card#me>;
4+
<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> .
5+
<#Restricted>
6+
<http://www.w3.org/ns/auth/acl#accessTo> <./abc2.ttl>;
7+
<http://www.w3.org/ns/auth/acl#agent> <https://user2.databox.me/profile/card#me>;
8+
<http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read>, <http://www.w3.org/ns/auth/acl#Write>.

test/resources/acl/empty-acl/.acl

Whitespace-only changes.

0 commit comments

Comments
 (0)