From d80bb928f78b52576efdf76489b2cbfdccd526bf Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 28 Apr 2019 13:51:42 -0400 Subject: [PATCH] feat: okta auth module --- .../authentication/okta/authentication.js | 23 ++++++++++++------- .../authentication/okta/definition.yml | 16 +++++++++++-- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/server/modules/authentication/okta/authentication.js b/server/modules/authentication/okta/authentication.js index 96497fcf..19411f4e 100644 --- a/server/modules/authentication/okta/authentication.js +++ b/server/modules/authentication/okta/authentication.js @@ -5,6 +5,7 @@ // ------------------------------------ const OktaStrategy = require('passport-okta-oauth').Strategy +const _ = require('lodash') module.exports = { init (passport, conf) { @@ -15,14 +16,20 @@ module.exports = { clientSecret: conf.clientSecret, idp: conf.idp, callbackURL: conf.callbackURL, - response_type: 'code', - scope: ['openid', 'email', 'profile'] - }, (accessToken, refreshToken, profile, cb) => { - WIKI.models.users.processProfile(profile).then((user) => { - return cb(null, user) || true - }).catch((err) => { - return cb(err, null) || true - }) + response_type: 'code' + }, async (accessToken, refreshToken, profile, cb) => { + try { + const user = await WIKI.models.users.processProfile({ + profile: { + ...profile, + picture: _.get(profile, '_json.profile', '') + }, + providerKey: 'okta' + }) + cb(null, user) + } catch (err) { + cb(err, null) + } }) ) } diff --git a/server/modules/authentication/okta/definition.yml b/server/modules/authentication/okta/definition.yml index f39f0c44..28a89a59 100644 --- a/server/modules/authentication/okta/definition.yml +++ b/server/modules/authentication/okta/definition.yml @@ -5,18 +5,30 @@ author: requarks.io logo: https://static.requarks.io/logo/okta.svg color: blue darken-1 website: https://www.okta.com/ +isAvailable: true useForm: false +scopes: + - profile + - email + - openid props: clientId: + title: Client ID type: String hint: 20 chars alphanumeric string + order: 2 clientSecret: + title: Client Secret type: String hint: 40 chars alphanumeric string with a hyphen(s) + order: 3 idp: title: Identity Provider ID (idp) type: String - hint: (optional) 20 chars alphanumeric string + hint: (Optional) - 20 chars alphanumeric string + order: 4 audience: + title: Org URL type: String - hint: Okta domain (e.g. https://example.okta.com, https://example.oktapreview.com) + hint: Okta organization URL (e.g. https://example.okta.com, https://example.oktapreview.com), found on the Developer Dashboard, in the upper right. + order: 1