123456789101112131415161718192021222324252627282930313233343536373839 |
- const _ = require('lodash')
- /* global WIKI */
- // ------------------------------------
- // OpenID Connect Account
- // ------------------------------------
- const OpenIDConnectStrategy = require('passport-openidconnect').Strategy
- module.exports = {
- init (passport, conf) {
- passport.use('oidc',
- new OpenIDConnectStrategy({
- authorizationURL: conf.authorizationURL,
- tokenURL: conf.tokenURL,
- clientID: conf.clientId,
- clientSecret: conf.clientSecret,
- issuer: conf.issuer,
- userInfoURL: conf.userInfoURL,
- callbackURL: conf.callbackURL,
- passReqToCallback: true
- }, async (req, iss, sub, profile, cb) => {
- try {
- const user = await WIKI.models.users.processProfile({
- providerKey: req.params.strategy,
- profile: {
- ...profile,
- email: _.get(profile, '_json.' + conf.emailClaim)
- }
- })
- cb(null, user)
- } catch (err) {
- cb(err, null)
- }
- })
- )
- }
- }
|