From d5c1f22ef5056a3444da51dd386f097ec3bcc5e3 Mon Sep 17 00:00:00 2001 From: nicola Date: Thu, 12 May 2016 12:09:44 -0400 Subject: [PATCH 1/5] implementing OIDC for new account creation --- lib/identity-provider.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/identity-provider.js b/lib/identity-provider.js index 5f25fcfbb..e1c6927d5 100644 --- a/lib/identity-provider.js +++ b/lib/identity-provider.js @@ -1,4 +1,4 @@ -module.exports = IdentityProvider +.module.exports = IdentityProvider var webid = require('webid') var $rdf = require('rdflib') @@ -516,13 +516,16 @@ IdentityProvider.prototype.post = function (req, res, next) { waterfall([ function (callback) { - if (options.spkac && options.spkac.length > 0) { + if (this.auth === 'tls' && options.spkac && options.spkac.length > 0) { spkac = new Buffer(stripLineEndings(options.spkac), 'utf-8') webid('tls').generate({ spkac: spkac, agent: agent // TODO generate agent }, callback) - } else { + } else if (this.auth === 'oidc') { + const oidc = req.app.locals.oidc + oidc.users.create({}) + return callback(null, false) } }, From cf0a249591722743406604fc868312bd5314ca54 Mon Sep 17 00:00:00 2001 From: nicola Date: Thu, 12 May 2016 12:20:28 -0400 Subject: [PATCH 2/5] adding create user call in new --- lib/identity-provider.js | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/lib/identity-provider.js b/lib/identity-provider.js index e1c6927d5..094615b74 100644 --- a/lib/identity-provider.js +++ b/lib/identity-provider.js @@ -516,18 +516,30 @@ IdentityProvider.prototype.post = function (req, res, next) { waterfall([ function (callback) { - if (this.auth === 'tls' && options.spkac && options.spkac.length > 0) { - spkac = new Buffer(stripLineEndings(options.spkac), 'utf-8') - webid('tls').generate({ - spkac: spkac, - agent: agent // TODO generate agent - }, callback) - } else if (this.auth === 'oidc') { - const oidc = req.app.locals.oidc - oidc.users.create({}) - - return callback(null, false) + if (this.auth !== 'oidc') { + return callback } + const oidc = req.app.locals.oidc + + return oidc.users + .create({ + email: options.email, + profile: agent, + name: options.name + }) + .then(callback) + .catch(callback) + }, + function (callback) { + if (!(this.auth === 'tls' && options.spkac && options.spkac.length > 0)) { + return callback() + } + + spkac = new Buffer(stripLineEndings(options.spkac), 'utf-8') + webid('tls').generate({ + spkac: spkac, + agent: agent // TODO generate agent + }, callback) }, function (newCert, callback) { cert = newCert @@ -545,9 +557,9 @@ IdentityProvider.prototype.post = function (req, res, next) { if (err) debug('Error sending email', err) callback() }) - } else { - callback() + return } + callback() } ], function (err) { if (err) { From 64991c0609e5da30f709f329173559b026b717a5 Mon Sep 17 00:00:00 2001 From: nicola Date: Thu, 12 May 2016 12:39:25 -0400 Subject: [PATCH 3/5] oidc in new --- lib/identity-provider.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/identity-provider.js b/lib/identity-provider.js index 094615b74..9a902ca05 100644 --- a/lib/identity-provider.js +++ b/lib/identity-provider.js @@ -1,4 +1,4 @@ -.module.exports = IdentityProvider +module.exports = IdentityProvider var webid = require('webid') var $rdf = require('rdflib') @@ -515,24 +515,24 @@ IdentityProvider.prototype.post = function (req, res, next) { debug('Create account with settings ', options) waterfall([ - function (callback) { + (callback) => { if (this.auth !== 'oidc') { - return callback + return callback() } - const oidc = req.app.locals.oidc + const oidc = req.app.locals.oidc return oidc.users .create({ email: options.email, profile: agent, name: options.name }) - .then(callback) + .then(() => callback()) .catch(callback) }, - function (callback) { + (callback) => { if (!(this.auth === 'tls' && options.spkac && options.spkac.length > 0)) { - return callback() + return callback(null, false) } spkac = new Buffer(stripLineEndings(options.spkac), 'utf-8') @@ -557,9 +557,9 @@ IdentityProvider.prototype.post = function (req, res, next) { if (err) debug('Error sending email', err) callback() }) - return + } else { + callback() } - callback() } ], function (err) { if (err) { From 25c7c1576f89505535d9c6ad0cfc82f9fc9e7d1d Mon Sep 17 00:00:00 2001 From: nicola Date: Thu, 12 May 2016 12:41:17 -0400 Subject: [PATCH 4/5] client is under .client --- lib/identity-provider.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/identity-provider.js b/lib/identity-provider.js index 9a902ca05..9ccecb4fb 100644 --- a/lib/identity-provider.js +++ b/lib/identity-provider.js @@ -521,7 +521,7 @@ IdentityProvider.prototype.post = function (req, res, next) { } const oidc = req.app.locals.oidc - return oidc.users + return oidc.client.users .create({ email: options.email, profile: agent, From 27fffd29a8b92494e8bcf4fb4bed21fc56d7cfcf Mon Sep 17 00:00:00 2001 From: nicola Date: Thu, 12 May 2016 12:49:41 -0400 Subject: [PATCH 5/5] adding password --- lib/identity-provider.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/identity-provider.js b/lib/identity-provider.js index 9ccecb4fb..31b95cd40 100644 --- a/lib/identity-provider.js +++ b/lib/identity-provider.js @@ -525,7 +525,8 @@ IdentityProvider.prototype.post = function (req, res, next) { .create({ email: options.email, profile: agent, - name: options.name + name: options.name, + password: options.password }) .then(() => callback()) .catch(callback)