Skip to content

Commit c565cea

Browse files
committed
Change sharing to consent | update sharing copy
1 parent e070c34 commit c565cea

File tree

13 files changed

+123
-148
lines changed

13 files changed

+123
-148
lines changed

common/disclaimer.html

Lines changed: 0 additions & 44 deletions
This file was deleted.

default-views/auth/consent.hbs

Lines changed: 0 additions & 48 deletions
This file was deleted.

default-views/auth/sharing.hbs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<title>{{title}}</title>
7+
<!-- Bootstrap CSS and Theme for demo purposes -->
8+
<link rel="stylesheet" href="/common/css/bootstrap.min.css">
9+
<link rel="stylesheet" href="/common/css/solid.css">
10+
</head>
11+
<body>
12+
<div class="container title">
13+
<h1>Authorize {{app_origin}} to access your Pod?</h1>
14+
<p>Solid allows you to precisely choose what other people and apps can read and write in a Pod. This version of the authorization user interface (node-solid-server V5.1.1) only supports the toggle of global access permissions to all of the data in your Pod.</p>
15+
<p><strong>If you don’t want to set these permissions at a global level, uncheck all of the boxes below, then click authorize.</strong> This will add the application origin to your authorization list, without granting it permission to any of your data yet. You will then need to manage those permissions yourself by setting them explicitly in the places you want this application to access.</p>
16+
<div class="panel panel-default">
17+
<div class="panel-body">
18+
<div class="page-title">
19+
<p>By clicking Authorize, any app from {{app_origin}} will be able to:</p>
20+
</div>
21+
<form method="post" action="/sharing">
22+
23+
<input id="read" type="checkbox" name="access_mode" value="Read" checked>
24+
<label for="read">Read all documents in the Pod</label>
25+
<br>
26+
27+
<input id="write" type="checkbox" name="access_mode" value="Write" checked>
28+
<label for="write">Add data to existing documents, and create new documents</label>
29+
<br>
30+
31+
<input id="append" type="checkbox" name="access_mode" value="Append" checked>
32+
<label for="append">Modify and delete data in existing documents, and delete documents</label>
33+
<br>
34+
35+
<input id="control" type="checkbox" name="access_mode" value="Control">
36+
<label for="control">Give other people and apps access to the Pod, or revoke their (and your) access</label>
37+
<br>
38+
<br>
39+
40+
<button type="submit" class="btn btn-primary" name="consent" value="true">Authorize</button>
41+
<button type="submit" class="btn btn-default" name="cancel" value="true">Cancel</button>
42+
{{> auth/auth-hidden-fields}}
43+
</form>
44+
</div>
45+
</div>
46+
<p><i>This server (node-solid-server V5.1.1) only implements a limited subset of OpenID Connect, and doesn’t yet support token issuance for applications. OIDC Token Issuance and fine-grained management through this authorization user interface is currently in the development backlog for node-solid-server</i></p>
47+
</div>
48+
</body>
49+
</html>

lib/api/authn/webid-oidc.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const { routeResolvedFile } = require('../../utils')
88
const bodyParser = require('body-parser').urlencoded({ extended: false })
99
const OidcManager = require('../../models/oidc-manager')
1010
const { LoginRequest } = require('../../requests/login-request')
11-
const { ConsentRequest } = require('../../requests/consent-request')
11+
const { SharingRequest } = require('../../requests/sharing-request')
1212

1313
const restrictToTopDomain = require('../../handlers/restrict-to-top-domain')
1414

@@ -84,8 +84,8 @@ function middleware (oidc) {
8484

8585
router.post('/login/tls', bodyParser, LoginRequest.loginTls)
8686

87-
router.get('/consent', ConsentRequest.get)
88-
router.post('/consent', bodyParser, ConsentRequest.giveConsent)
87+
router.get('/sharing', SharingRequest.get)
88+
router.post('/sharing', bodyParser, SharingRequest.share)
8989

9090
router.get('/account/password/reset', restrictToTopDomain, PasswordResetEmailRequest.get)
9191
router.post('/account/password/reset', restrictToTopDomain, bodyParser, PasswordResetEmailRequest.post)

lib/requests/auth-request.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,13 @@ class AuthRequest {
218218
return url.format(signupUrl)
219219
}
220220

221-
consentUrl () {
221+
sharingUrl () {
222222
let host = this.accountManager.host
223-
let consentUrl = url.parse(url.resolve(host.serverUri, '/consent'))
223+
let sharingUrl = url.parse(url.resolve(host.serverUri, '/sharing'))
224224

225-
consentUrl.query = this.authQueryParams
225+
sharingUrl.query = this.authQueryParams
226226

227-
return url.format(consentUrl)
227+
return url.format(sharingUrl)
228228
}
229229
}
230230

lib/requests/login-request.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class LoginRequest extends AuthRequest {
159159
postLoginUrl (validUser) {
160160
// Login request is part of an app's auth flow
161161
if (/token|code/.test(this.authQueryParams['response_type'])) {
162-
return this.consentUrl()
162+
return this.sharingUrl()
163163
// Login request is a user going to /login in browser
164164
} else if (validUser) {
165165
return this.authQueryParams['redirect_uri'] || validUser.accountUri
Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const ACL = $rdf.Namespace('http://www.w3.org/ns/auth/acl#')
1313
/**
1414
* Models a local Login request
1515
*/
16-
class ConsentRequest extends AuthRequest {
16+
class SharingRequest extends AuthRequest {
1717
/**
1818
* @constructor
1919
* @param options {Object}
@@ -48,7 +48,7 @@ class ConsentRequest extends AuthRequest {
4848
static fromParams (req, res) {
4949
let options = AuthRequest.requestOptions(req, res)
5050

51-
return new ConsentRequest(options)
51+
return new SharingRequest(options)
5252
}
5353

5454
/**
@@ -64,7 +64,7 @@ class ConsentRequest extends AuthRequest {
6464
* @param res {ServerResponse}
6565
*/
6666
static async get (req, res) {
67-
const request = ConsentRequest.fromParams(req, res)
67+
const request = SharingRequest.fromParams(req, res)
6868

6969
const appUrl = request.getAppUrl()
7070
const appOrigin = `${appUrl.protocol}//${appUrl.host}`
@@ -75,10 +75,10 @@ class ConsentRequest extends AuthRequest {
7575
(appUrl && request.isSubdomain(serverUrl.host, appUrl.host) && appUrl.protocol === serverUrl.protocol) ||
7676
await request.isAppRegistered(req.app.locals.ldp, appOrigin, request.session.subject._id)
7777
) {
78-
request.setUserConsent(appOrigin)
79-
request.redirectPostConsent()
78+
request.setUserShared(appOrigin)
79+
request.redirectPostSharing()
8080
} else {
81-
request.renderForm(null, req)
81+
request.renderForm(null, req, appOrigin)
8282
}
8383
}
8484
}
@@ -92,7 +92,7 @@ class ConsentRequest extends AuthRequest {
9292
*
9393
* @return {Promise}
9494
*/
95-
static async giveConsent (req, res) {
95+
static async share (req, res) {
9696
let accessModes = []
9797
let consented = false
9898
if (req.body) {
@@ -103,20 +103,20 @@ class ConsentRequest extends AuthRequest {
103103
consented = req.body.consent
104104
}
105105

106-
let request = ConsentRequest.fromParams(req, res)
106+
let request = SharingRequest.fromParams(req, res)
107107

108108
if (request.isUserLoggedIn()) {
109109
const appUrl = request.getAppUrl()
110110
const appOrigin = `${appUrl.protocol}//${appUrl.host}`
111-
debug('Providing consent for app sharing')
111+
debug('Sharing App')
112112

113113
if (consented) {
114114
await request.registerApp(req.app.locals.ldp, appOrigin, accessModes, request.session.subject._id)
115-
request.setUserConsent(appOrigin)
115+
request.setUserShared(appOrigin)
116116
}
117117

118118
// Redirect once that's all done
119-
request.redirectPostConsent()
119+
request.redirectPostSharing()
120120
}
121121
}
122122

@@ -131,7 +131,7 @@ class ConsentRequest extends AuthRequest {
131131
return true
132132
}
133133

134-
setUserConsent (appOrigin) {
134+
setUserShared (appOrigin) {
135135
if (!this.session.consentedOrigins) {
136136
this.session.consentedOrigins = []
137137
}
@@ -215,42 +215,43 @@ class ConsentRequest extends AuthRequest {
215215
*
216216
* @return {string}
217217
*/
218-
postConsentUrl () {
218+
postSharingUrl () {
219219
return this.authorizeUrl()
220220
}
221221

222222
/**
223223
* Redirects the Login request to continue on the OIDC auth workflow.
224224
*/
225-
redirectPostConsent () {
226-
let uri = this.postConsentUrl()
225+
redirectPostSharing () {
226+
let uri = this.postSharingUrl()
227227
debug('Login successful, redirecting to ', uri)
228228
this.response.redirect(uri)
229229
}
230230

231231
/**
232232
* Renders the login form
233233
*/
234-
renderForm (error, req) {
234+
renderForm (error, req, appOrigin) {
235235
let queryString = req && req.url && req.url.replace(/[^?]+\?/, '') || ''
236236
let params = Object.assign({}, this.authQueryParams,
237237
{
238238
registerUrl: this.registerUrl(),
239239
returnToUrl: this.returnToUrl,
240240
enablePassword: this.localAuth.password,
241241
enableTls: this.localAuth.tls,
242-
tlsUrl: `/login/tls?${encodeURIComponent(queryString)}`
242+
tlsUrl: `/login/tls?${encodeURIComponent(queryString)}`,
243+
app_origin: appOrigin
243244
})
244245

245246
if (error) {
246247
params.error = error.message
247248
this.response.status(error.statusCode)
248249
}
249250

250-
this.response.render('auth/consent', params)
251+
this.response.render('auth/sharing', params)
251252
}
252253
}
253254

254255
module.exports = {
255-
ConsentRequest
256+
SharingRequest
256257
}

test/integration/authentication-oidc-test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ describe('Authentication API (OIDC)', () => {
528528
let bearerToken
529529
let postLoginUri
530530
let cookie
531-
let postConsentUri
531+
let postSharingUri
532532

533533
before(() => {
534534
auth = new SolidAuthOIDC({ store: localStorage, window: { location: {} } })
@@ -635,16 +635,16 @@ describe('Authentication API (OIDC)', () => {
635635

636636
// Successful login gets redirected back to /authorize and then
637637
// back to app
638-
expect(postLoginUri.startsWith(aliceServerUri + '/consent'))
638+
expect(postLoginUri.startsWith(aliceServerUri + '/sharing'))
639639
.to.be.true()
640640
})
641641
})
642642

643-
// Step 6: User consents to the app accessing certain things
644-
it('should consent via the /consent form', () => {
643+
// Step 6: User shares with the app accessing certain things
644+
it('should consent via the /sharing form', () => {
645645
loginFormFields += `&access_mode=Read&access_mode=Write&consent=true`
646646

647-
return fetch(aliceServerUri + '/consent', {
647+
return fetch(aliceServerUri + '/sharing', {
648648
method: 'POST',
649649
body: loginFormFields,
650650
redirect: 'manual',
@@ -656,14 +656,14 @@ describe('Authentication API (OIDC)', () => {
656656
})
657657
.then(res => {
658658
expect(res.status).to.equal(302)
659-
postConsentUri = res.headers.get('location')
659+
postSharingUri = res.headers.get('location')
660660
// cookie = res.headers.get('set-cookie')
661661

662662
// Successful login gets redirected back to /authorize and then
663663
// back to app
664-
expect(postConsentUri.startsWith(aliceServerUri + '/authorize'))
664+
expect(postSharingUri.startsWith(aliceServerUri + '/authorize'))
665665
.to.be.true()
666-
return fetch(postConsentUri, { redirect: 'manual', headers: { cookie } })
666+
return fetch(postSharingUri, { redirect: 'manual', headers: { cookie } })
667667
})
668668
.then(res => {
669669
// User gets redirected back to original app

test/integration/authentication-oidc-with-strict-origins-turned-off-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,16 +507,16 @@ describe('Authentication API (OIDC) - With strict origins turned off', () => {
507507

508508
// Successful login gets redirected back to /authorize and then
509509
// back to app
510-
expect(postLoginUri.startsWith(aliceServerUri + '/consent'))
510+
expect(postLoginUri.startsWith(aliceServerUri + '/sharing'))
511511
.to.be.true()
512512
})
513513
})
514514

515515
// Step 6: User consents to the app accessing certain things
516-
it('should consent via the /consent form', () => {
516+
it('should consent via the /sharing form', () => {
517517
loginFormFields += `&access_mode=Read&access_mode=Write&consent=true`
518518

519-
return fetch(aliceServerUri + '/consent', {
519+
return fetch(aliceServerUri + '/sharing', {
520520
method: 'POST',
521521
body: loginFormFields,
522522
redirect: 'manual',

0 commit comments

Comments
 (0)