Skip to content

Commit 10c7711

Browse files
author
nicola
committed
return iframe with the new spkac
1 parent 8752afe commit 10c7711

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

‎lib/identity-provider.js‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ IdentityProvider.prototype.post = function (req, res, next) {
272272

273273
var agent = self.agent(req.body)
274274

275+
var cert = null
275276
waterfall([
276277
function (callback) {
277278
if (req.body['spkac'] && req.body['spkac'].length > 0) {
@@ -283,7 +284,8 @@ IdentityProvider.prototype.post = function (req, res, next) {
283284
return callback(null, false)
284285
}
285286
},
286-
function (cert, callback) {
287+
function (newSpkac, callback) {
288+
cert = newSpkac
287289
self.create(req.body, cert, callback)
288290
}
289291
], function (err) {
@@ -294,8 +296,16 @@ IdentityProvider.prototype.post = function (req, res, next) {
294296
// Set the cookies on success
295297
req.session.agent = agent
296298
res.set('User', agent)
299+
res.status(201)
300+
301+
if (cert) {
302+
res.set('Content-Type', 'text/html')
303+
var encodedSpkac = new Buffer(cert).toString('base64')
304+
res.send('<iframe width="0" height="0" style="display: none;" src="data:application/x-x509-user-cert;base64,' + encodedSpkac + '"></iframe>')
305+
} else {
306+
res.end()
307+
}
297308

298-
res.send(201)
299309
})
300310
}
301311

‎test/identity-provider.js‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ describe('Identity Provider', function () {
8080
done(err)
8181
})
8282
})
83+
it.skip('should return text/html with a frame and a certificate if spkac is passed', function (done) {
84+
// var spkac = null // TODO this should be a spkac
85+
server.post('/accounts')
86+
.send('username=nicola')
87+
.expect(201)
88+
.expect('Content-Type', 'text/html')
89+
.end(function (err) {
90+
done(new Error('Test not implemented yet'))
91+
rm('accounts/nicola.localhost:3457')
92+
done(err)
93+
})
94+
})
8395
it('should not create a WebID if it already exists', function (done) {
8496
server.post('/accounts')
8597
.send('username=nicola')

0 commit comments

Comments
 (0)