Skip to content

Commit 3ca6e97

Browse files
committed
create defaultAcl with --owner
1 parent 17c7d8a commit 3ca6e97

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

bin/ldnode.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ var argv = require('nomnom')
2929
full: 'webid',
3030
flag: true
3131
})
32+
.option('owner', {
33+
help: 'Set the owner of the storage'
34+
})
3235
.option('key', {
3336
help: 'Path to the SSL private key in PEM format',
3437
full: 'ssl-key'
@@ -129,6 +132,35 @@ function bin (argv) {
129132
})
130133
}
131134

135+
if (argv.owner) {
136+
var rootPath = argv.root
137+
if (!rootPath) {
138+
rootPath = process.cwd()
139+
}
140+
if (!(rootPath.endsWith('/'))) {
141+
rootPath += '/'
142+
}
143+
rootPath += (argv.suffixAcl || '.acl')
144+
145+
var defaultAcl = `@prefix n0: <http://www.w3.org/ns/auth/acl#>.
146+
@prefix n2: <http://xmlns.com/foaf/0.1/>.
147+
148+
<#owner>
149+
a n0:Authorization;
150+
n0:accessTo <./>;
151+
n0:agent <${argv.owner}>;
152+
n0:defaultForNew <./>;
153+
n0:mode n0:Control, n0:Read, n0:Write.
154+
<#everyone>
155+
a n0:Authorization;
156+
n0: n2:Agent;
157+
n0:accessTo <./>;
158+
n0:defaultForNew <./>;
159+
n0:mode n0:Read.' > .acl`
160+
161+
fs.writeFileSync(rootPath, defaultAcl)
162+
}
163+
132164
// Finally starting ldnode
133165
var ldnode = require('../')
134166
var app

lib/create-app.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ function createApp (argv) {
104104
}
105105

106106
app.get('/', function (req, res, next) {
107+
// Do not bother showing html page can't be read
108+
if (!req.accepts('text/html') || !ldp.webid) {
109+
return next()
110+
}
111+
107112
checkMasterAcl(req, function (found) {
108113
if (!found) {
109114
res.set('Content-Type', 'text/html')

0 commit comments

Comments
 (0)