Skip to content

Commit 0b1b108

Browse files
committed
fixing links in readme
2 parents 7b9f92e + e846e6b commit 0b1b108

6 files changed

Lines changed: 65 additions & 32 deletions

File tree

.gitignore

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,3 @@ node_modules/
33
*.swp
44
.tern-port
55
npm-debug.log
6-
.acl
7-
profile/
8-
accounts/
9-
settings/
10-
temp/

README.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,8 @@ $ solid --port 8443 --ssl-key path/to/ssl-key.pem --ssl-cert path/to/ssl-cert.pe
3737
# Solid server (solid v0.2.24) running on https://localhost:8443/
3838
```
3939

40-
First time user? If you have never run `solid` before, let's get you a WebID to access your server.
41-
```bash
42-
43-
$ solid --port 8443 --ssl-key path/to/ssl-key.pem --ssl-cert path/to/ssl-cert.pem
44-
# Action required: Create your admin account on https://localhost:8080/
45-
# When done, stop your server (<ctrl>+c) and restart without "--create-admin"
46-
```
47-
4840
If you want to run `solid` on a particular folder (different from the one you are in, e.g. `path/to/folder`):
41+
4942
```bash
5043
$ solid --root path/to/folder --port 8443 --ssl-key path/to/ssl-key.pem --ssl-cert path/to/ssl-cert.pem
5144
# Solid server (solid v0.2.24) running on https://localhost:8443/
@@ -105,11 +98,10 @@ Options:
10598
--ssl-cert Path to the SSL certificate key in PEM format
10699
--allow-signup Allow users to register their WebID on subdomains
107100
108-
--create-admin Allow a user to set up their initial identity in single-user mode
109101
--no-live Disable live support through WebSockets
110-
--default-app URI to use as a default app for resources (default: https://solid.github.io/warp/#/list/)
102+
--default-app URI to use as a default app for resources (default: https://linkeddata.github.io/warp/#/list/)
111103
--proxy Use a proxy on example.tld/proxyPath
112-
--file-browser URI to use as a default app for resources (default: https://solid.github.io/warp/#/list/)
104+
--file-browser URI to use as a default app for resources (default: https://linkeddata.github.io/warp/#/list/)
113105
--data-browser Enable viewing RDF resources using a default data browser application (e.g. mashlib)
114106
--suffix-acl Suffix for acl files (default: '.acl')
115107
--suffix-meta Suffix for metadata files (default: '.meta')
@@ -245,7 +237,7 @@ above, you would then be able to visit `https://localhost:8443` in the browser
245237
(ignoring the Untrusted Connection browser warnings as usual), where your
246238
`solid` server would redirect you to the default viewer app (see the
247239
`--file-browser` server config parameter), which is usually the
248-
[github.io/warp](https://solid.github.io/warp/#/list/) file browser.
240+
[github.io/warp](https://linkeddata.github.io/warp/#/list/) file browser.
249241

250242
Accessing most Solid apps (such as Warp) will prompt you to select your browser
251243
side certificate which contains a WebID from a Solid storage provider (see

lib/create-app.js

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,21 @@ function createApp (argv) {
2424
var ldp = new LDP(argv)
2525
var app = express()
2626

27+
// check if we have master ACL or not
28+
var masterAcl
29+
var checkMasterAcl = function (req, callback) {
30+
if (masterAcl) {
31+
return callback(true)
32+
}
33+
34+
ldp.exists(req.hostname, '/' + ldp.suffixAcl, function (err) {
35+
if (!err) {
36+
masterAcl = true
37+
}
38+
callback(!err)
39+
})
40+
}
41+
2742
// Setting options as local variable
2843
app.locals.ldp = ldp
2944

@@ -63,29 +78,49 @@ function createApp (argv) {
6378
}
6479

6580
// Adding Multi-user support
66-
if (ldp.idp || ldp.createAdmin) {
81+
if (ldp.webid) {
6782
var idp = IdentityProvider({
6883
store: ldp,
6984
suffixAcl: ldp.suffixAcl,
70-
overwrite: ldp.createAdmin,
7185
settings: 'settings',
7286
inbox: 'inbox'
7387
})
74-
app.use('/accounts', idp.middleware(corsSettings))
88+
var needsOverwrite = function (req, res, next) {
89+
checkMasterAcl(req, function (found) {
90+
if (!found) {
91+
// this allows IdentityProvider to overwrite root acls
92+
idp.middleware(corsSettings, true)(req, res, next)
93+
} else if (found && ldp.idp) {
94+
idp.middleware(corsSettings)(req, res, next)
95+
} else {
96+
next()
97+
}
98+
})
99+
}
100+
app.use('/accounts', needsOverwrite)
75101
app.use('/', corsSettings, idp.get.bind(idp))
76102
}
77103

78104
if (ldp.idp) {
79105
app.use(vhost('*', LdpMiddleware(corsSettings)))
80106
}
81107

82-
if (ldp.createAdmin) {
83-
app.get('/', function (req, res) {
84-
res.set('Content-Type', 'text/html')
85-
var signup = path.join(__dirname, '../static/signup.html')
86-
res.sendFile(signup)
108+
app.get('/', function (req, res, next) {
109+
// Do not bother showing html page can't be read
110+
if (!req.accepts('text/html') || !ldp.webid) {
111+
return next()
112+
}
113+
114+
checkMasterAcl(req, function (found) {
115+
if (!found) {
116+
res.set('Content-Type', 'text/html')
117+
var signup = path.join(__dirname, '../static/signup.html')
118+
res.sendFile(signup)
119+
} else {
120+
next()
121+
}
87122
})
88-
}
123+
})
89124
app.use('/', LdpMiddleware(corsSettings))
90125

91126
return app

lib/identity-provider.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ function IdentityProvider (options) {
3939
this.buildURI = options.buildURI || defaultBuildURI
4040
this.suffixAcl = options.suffixAcl
4141
this.defaultContainers = options.defaultContainers || defaultContainers
42-
this.overwrite = options.overwrite
4342
this.inbox = options.inbox
4443
this.settings = options.settings
4544
}
@@ -113,7 +112,7 @@ IdentityProvider.prototype.create = function (options, cert, callback) {
113112
var subdomain = options.host.split(':')[0]
114113
self.store.exists(subdomain, '/', function (err) {
115114
// if page exists, cannot create account
116-
if (!self.overwrite && (!err || err.status !== 404)) {
115+
if (!options.firstUser && (!err || err.status !== 404)) {
117116
debug('Cannot create ' + subdomain + ', it already exists')
118117
var error = new Error('Account already exists')
119118
error.status = 406
@@ -511,6 +510,7 @@ IdentityProvider.prototype.post = function (req, res, next) {
511510
var self = this
512511
var options = req.body
513512
options.host = req.get('host')
513+
options.firstUser = res.locals.firstUser
514514
var agent = self.agent(options)
515515
var spkac = null
516516
var cert = null
@@ -558,14 +558,15 @@ IdentityProvider.prototype.post = function (req, res, next) {
558558
}
559559

560560
// Middleware (or Router) to serve the IdentityProvider
561-
IdentityProvider.prototype.middleware = function (corsSettings) {
561+
IdentityProvider.prototype.middleware = function (corsSettings, firstUser) {
562562
var router = express.Router('/')
563563
var parser = bodyParser.urlencoded({ extended: false })
564564

565565
if (corsSettings) {
566566
router.use(corsSettings)
567567
}
568-
router.post('/new', parser, this.post.bind(this))
568+
569+
router.post('/new', parser, setFirstUser(firstUser), this.post.bind(this))
569570
router.post('/cert', parser, this.newCert.bind(this))
570571
router.all('/*', function (req, res) {
571572
var host = uriAbs(req)
@@ -576,3 +577,10 @@ IdentityProvider.prototype.middleware = function (corsSettings) {
576577

577578
return router
578579
}
580+
581+
function setFirstUser (isFirstUser) {
582+
return function (req, res, next) {
583+
res.locals.firstUser = isFirstUser
584+
next()
585+
}
586+
}

static/signup.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ <h2>Finish by issuing credentials in the form of a certificate</h2>
9797
document.getElementById('cert').style.display = 'none'
9898
var done = document.createElement('div')
9999
done.innerHTML = '<h2>You\'re all set!</h2>'
100-
done.innerHTML += '<p>Please restart your server without the <strong>--create-admin</strong> parameter.</p>'
101-
done.innerHTML += '<p>If an error occured and a certificate was not installed, please reload this page and start again.</p>'
100+
done.innerHTML += '<p>as soon as you will reset the page, you will be logged in!</p>'
102101
document.querySelector('body').appendChild(done)
103102
}
104103

test/resources/acl/owner-only/.acl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<#0>
2+
<http://www.w3.org/ns/auth/acl#defaultForNew> <./> ;
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#Write>, <http://www.w3.org/ns/auth/acl#Control>.

0 commit comments

Comments
 (0)