Skip to content

Commit c541a0a

Browse files
RubenVerborghdmitrizagidulin
authored andcommitted
Add acceptCertificateHeader option.
1 parent 97322a0 commit c541a0a

4 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎bin/lib/options.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ module.exports = [
7575
return answers.webid
7676
}
7777
},
78+
{
79+
name: 'acceptCertificateHeader',
80+
question: 'Accept client certificates through the X-SSL-Cert header (for reverse proxies)',
81+
default: false,
82+
prompt: false
83+
},
7884
{
7985
name: 'useOwner',
8086
question: 'Do you already have a WebID?',

‎lib/api/authn/webid-tls.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ function getCertificateViaTLS (req) {
4949

5050
// Tries to obtain a client certificate retrieved through the X-SSL-Cert header
5151
function getCertificateViaHeader (req) {
52+
// Only allow the X-SSL-Cert header if explicitly enabled
53+
if (!req.app.locals.acceptCertificateHeader) return
54+
5255
// Try to retrieve the certificate from the header
5356
const header = req.headers['x-ssl-cert']
5457
if (!header) {

‎lib/create-app.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ function initAuthentication (argv, app) {
187187
case 'tls':
188188
// Enforce authentication with WebID-TLS on all LDP routes
189189
app.use('/', API.tls.authenticate())
190+
app.locals.acceptCertificateHeader = argv.acceptCertificateHeader
190191
break
191192
case 'oidc':
192193
let oidc = OidcManager.fromServerConfig(argv)

‎test/integration/acl-tls.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,8 @@ describe('ACL with WebID through X-SSL-Cert', function () {
985985
sslCert: path.join(__dirname, '../keys/cert.pem'),
986986
webid: true,
987987
strictOrigin: true,
988-
auth: 'tls'
988+
auth: 'tls',
989+
acceptCertificateHeader: true
989990
})
990991
ldpHttpsServer = ldp.listen(3456, done)
991992
})

0 commit comments

Comments
 (0)