feat: okta auth module

This commit is contained in:
Nick 2019-04-28 13:51:42 -04:00
parent c03dae933f
commit d80bb928f7
2 changed files with 29 additions and 10 deletions

View File

@ -5,6 +5,7 @@
// ------------------------------------ // ------------------------------------
const OktaStrategy = require('passport-okta-oauth').Strategy const OktaStrategy = require('passport-okta-oauth').Strategy
const _ = require('lodash')
module.exports = { module.exports = {
init (passport, conf) { init (passport, conf) {
@ -15,14 +16,20 @@ module.exports = {
clientSecret: conf.clientSecret, clientSecret: conf.clientSecret,
idp: conf.idp, idp: conf.idp,
callbackURL: conf.callbackURL, callbackURL: conf.callbackURL,
response_type: 'code', response_type: 'code'
scope: ['openid', 'email', 'profile'] }, async (accessToken, refreshToken, profile, cb) => {
}, (accessToken, refreshToken, profile, cb) => { try {
WIKI.models.users.processProfile(profile).then((user) => { const user = await WIKI.models.users.processProfile({
return cb(null, user) || true profile: {
}).catch((err) => { ...profile,
return cb(err, null) || true picture: _.get(profile, '_json.profile', '')
},
providerKey: 'okta'
}) })
cb(null, user)
} catch (err) {
cb(err, null)
}
}) })
) )
} }

View File

@ -5,18 +5,30 @@ author: requarks.io
logo: https://static.requarks.io/logo/okta.svg logo: https://static.requarks.io/logo/okta.svg
color: blue darken-1 color: blue darken-1
website: https://www.okta.com/ website: https://www.okta.com/
isAvailable: true
useForm: false useForm: false
scopes:
- profile
- email
- openid
props: props:
clientId: clientId:
title: Client ID
type: String type: String
hint: 20 chars alphanumeric string hint: 20 chars alphanumeric string
order: 2
clientSecret: clientSecret:
title: Client Secret
type: String type: String
hint: 40 chars alphanumeric string with a hyphen(s) hint: 40 chars alphanumeric string with a hyphen(s)
order: 3
idp: idp:
title: Identity Provider ID (idp) title: Identity Provider ID (idp)
type: String type: String
hint: (optional) 20 chars alphanumeric string hint: (Optional) - 20 chars alphanumeric string
order: 4
audience: audience:
title: Org URL
type: String 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