Skip to content

Commit b753954

Browse files
Remove WebID-TLS authentication code
1 parent 477c0e0 commit b753954

File tree

16 files changed

+10
-1448
lines changed

16 files changed

+10
-1448
lines changed

bin/lib/options.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,11 @@ module.exports = [
6464
question: 'Select authentication strategy',
6565
type: 'list',
6666
choices: [
67-
'WebID-OpenID Connect',
68-
'WebID-TLS'
67+
'WebID-OpenID Connect'
6968
],
70-
prompt: true,
69+
prompt: false,
7170
default: 'WebID-OpenID Connect',
7271
filter: (value) => {
73-
if (value === 'WebID-TLS') return 'tls'
7472
if (value === 'WebID-OpenID Connect') return 'oidc'
7573
},
7674
when: (answers) => {

lib/api/authn/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,5 @@ function overrideWith (forceUserId) {
1818

1919
module.exports = {
2020
oidc: require('./webid-oidc'),
21-
tls: require('./webid-tls'),
2221
overrideWith
2322
}

lib/api/authn/webid-tls.js

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

lib/api/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@
33
module.exports = {
44
authn: require('./authn'),
55
oidc: require('./authn/webid-oidc'),
6-
tls: require('./authn/webid-tls'),
76
accounts: require('./accounts/user-accounts')
87
}

lib/create-app.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,6 @@ function initAuthentication (argv, app) {
175175
let authMethod = argv.auth
176176

177177
switch (authMethod) {
178-
case 'tls':
179-
// Enforce authentication with WebID-TLS on all LDP routes
180-
app.use('/', API.tls.authenticate())
181-
break
182178
case 'oidc':
183179
let oidc = OidcManager.fromServerConfig(argv)
184180
app.locals.oidc = oidc

lib/create-server.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ function createServer (argv, app) {
5858
cert: cert
5959
}
6060

61-
if (ldp.webid && ldp.auth === 'tls') {
62-
credentials.requestCert = true
63-
}
64-
6561
server = https.createServer(credentials, app)
6662
}
6763

lib/ldp.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ class LDP {
7575
this.skin = true
7676
}
7777

78-
if (this.webid && !this.auth) {
79-
this.auth = 'tls'
80-
}
81-
8278
if (this.proxy && this.proxy[ 0 ] !== '/') {
8379
this.proxy = '/' + this.proxy
8480
}

lib/models/account-manager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class AccountManager {
2323
/**
2424
* @constructor
2525
* @param [options={}] {Object}
26-
* @param [options.authMethod] {string} Primary authentication method (e.g. 'tls')
26+
* @param [options.authMethod] {string} Primary authentication method (e.g. 'oidc')
2727
* @param [options.emailService] {EmailService}
2828
* @param [options.tokenService] {TokenService}
2929
* @param [options.host] {SolidHost}

lib/requests/create-account-request.js

Lines changed: 1 addition & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict'
22

33
const AuthRequest = require('./auth-request')
4-
const WebIdTlsCertificate = require('../models/webid-tls-certificate')
54
const debug = require('../debug').accounts
65

76
/**
@@ -12,7 +11,7 @@ const debug = require('../debug').accounts
1211
* a command line, use the `AccountManager` class directly.
1312
*
1413
* This is an abstract class, subclasses are created (for example
15-
* `CreateTlsAccountRequest`) depending on which Authentication mode the server
14+
* `CreateOidcAccountRequest`) depending on which Authentication mode the server
1615
* is running in.
1716
*
1817
* @class CreateAccountRequest
@@ -73,9 +72,6 @@ class CreateAccountRequest extends AuthRequest {
7372
options.password = req.body.password
7473
options.userStore = locals.oidc.users
7574
return new CreateOidcAccountRequest(options)
76-
case 'tls':
77-
options.spkac = req.body.spkac
78-
return new CreateTlsAccountRequest(options)
7975
default:
8076
throw new TypeError('Unsupported authentication scheme')
8177
}
@@ -259,112 +255,5 @@ class CreateOidcAccountRequest extends CreateAccountRequest {
259255
}
260256
}
261257

262-
/**
263-
* Models a Create Account request for a server using WebID-TLS as primary
264-
* authentication mode. Handles generating and saving a TLS certificate, etc.
265-
*
266-
* @class CreateTlsAccountRequest
267-
* @extends CreateAccountRequest
268-
*/
269-
class CreateTlsAccountRequest extends CreateAccountRequest {
270-
/**
271-
* @constructor
272-
*
273-
* @param [options={}] {Object} See `CreateAccountRequest` constructor docstring
274-
* @param [options.spkac] {string}
275-
*/
276-
constructor (options = {}) {
277-
super(options)
278-
this.spkac = options.spkac
279-
this.certificate = null
280-
}
281-
282-
/**
283-
* Generates a new X.509v3 RSA certificate (if `spkac` was passed in) and
284-
* adds it to the user account. Used for storage in an agent's WebID
285-
* Profile, for WebID-TLS authentication.
286-
*
287-
* @param userAccount {UserAccount}
288-
* @param userAccount.webId {string} An agent's WebID URI
289-
*
290-
* @throws {Error} HTTP 400 error if errors were encountering during
291-
* certificate generation.
292-
*
293-
* @return {Promise<UserAccount>} Chainable
294-
*/
295-
generateTlsCertificate (userAccount) {
296-
if (!this.spkac) {
297-
debug('Missing spkac param, not generating cert during account creation')
298-
return Promise.resolve(userAccount)
299-
}
300-
301-
return Promise.resolve()
302-
.then(() => {
303-
let host = this.accountManager.host
304-
return WebIdTlsCertificate.fromSpkacPost(this.spkac, userAccount, host)
305-
.generateCertificate()
306-
})
307-
.catch(err => {
308-
err.status = 400
309-
err.message = 'Error generating a certificate: ' + err.message
310-
throw err
311-
})
312-
.then(certificate => {
313-
debug('Generated a WebID-TLS certificate as part of account creation')
314-
this.certificate = certificate
315-
return userAccount
316-
})
317-
}
318-
319-
/**
320-
* Generates a WebID-TLS certificate and saves it to the user's profile
321-
* graph.
322-
*
323-
* @param userAccount {UserAccount}
324-
*
325-
* @return {Promise<UserAccount>} Chainable
326-
*/
327-
saveCredentialsFor (userAccount) {
328-
return this.generateTlsCertificate(userAccount)
329-
.then(userAccount => {
330-
if (this.certificate) {
331-
return this.accountManager
332-
.addCertKeyToProfile(this.certificate, userAccount)
333-
.then(() => {
334-
debug('Saved generated WebID-TLS certificate to profile')
335-
})
336-
} else {
337-
debug('No certificate generated, no need to save to profile')
338-
}
339-
})
340-
.then(() => {
341-
return userAccount
342-
})
343-
}
344-
345-
/**
346-
* Writes the generated TLS certificate to the http Response object.
347-
*
348-
* @param userAccount {UserAccount}
349-
*
350-
* @return {UserAccount} Chainable
351-
*/
352-
sendResponse (userAccount) {
353-
let res = this.response
354-
res.set('User', userAccount.webId)
355-
res.status(200)
356-
357-
if (this.certificate) {
358-
res.set('Content-Type', 'application/x-x509-user-cert')
359-
res.send(this.certificate.toDER())
360-
} else {
361-
res.end()
362-
}
363-
364-
return userAccount
365-
}
366-
}
367-
368258
module.exports = CreateAccountRequest
369259
module.exports.CreateAccountRequest = CreateAccountRequest
370-
module.exports.CreateTlsAccountRequest = CreateTlsAccountRequest

0 commit comments

Comments
 (0)