mirror of https://github.com/Requarks/wiki.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
911 B
36 lines
911 B
/* global WIKI */
|
|
|
|
// ------------------------------------
|
|
// Okta Account
|
|
// ------------------------------------
|
|
|
|
const OktaStrategy = require('passport-okta-oauth').Strategy
|
|
const _ = require('lodash')
|
|
|
|
module.exports = {
|
|
init (passport, conf) {
|
|
passport.use('okta',
|
|
new OktaStrategy({
|
|
audience: conf.audience,
|
|
clientID: conf.clientId,
|
|
clientSecret: conf.clientSecret,
|
|
idp: conf.idp,
|
|
callbackURL: conf.callbackURL,
|
|
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)
|
|
}
|
|
})
|
|
)
|
|
}
|
|
}
|