Skip to content

Commit c9cbd8d

Browse files
author
Martin Martinez Rivera
committed
Added support for ACL in glob requests.
1 parent 2354a57 commit c9cbd8d

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

‎handlers/get.js‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var path = require('path');
88
var $rdf = require('rdflib');
99
var S = require('string');
1010

11+
var acl = require('../acl.js');
1112
var header = require('../header.js');
1213
var metadata = require('../metadata.js');
1314
var options = require('../options.js');
@@ -117,7 +118,7 @@ function get(req, res, includeBody) {
117118
{encoding: "utf8"});
118119
var baseUri = file.filenameToBaseUri(match);
119120
//TODO integrate ACL
120-
if (S(match).endsWith(".ttl")) {
121+
if (S(match).endsWith(".ttl") && aclAllow(match)) {
121122
$rdf.parse(fileData, globGraph, baseUri,
122123
'text/turtle');
123124
}
@@ -132,6 +133,22 @@ function get(req, res, includeBody) {
132133
});
133134
}
134135

136+
function aclAllow(match) {
137+
if (!options.webid) {
138+
return true;
139+
} else {
140+
var relativePath = '/' +
141+
path.relative(options.fileBase, match);
142+
req.path = relativePath;
143+
var allow = acl.allow("Read", req, res);
144+
if (allow.status === 200) {
145+
return true;
146+
} else {
147+
return false;
148+
}
149+
}
150+
}
151+
135152
function parseLinkedData(turtleData) {
136153
var accept = header.parseAcceptHeader(req);
137154
var baseUri = file.filenameToBaseUri(filename);

0 commit comments

Comments
 (0)