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

  1. /* global WIKI */
  2. // ------------------------------------
  3. // Okta Account
  4. // ------------------------------------
  5. const OktaStrategy = require('passport-okta-oauth').Strategy
  6. const _ = require('lodash')
  7. module.exports = {
  8. init (passport, conf) {
  9. passport.use('okta',
  10. new OktaStrategy({
  11. audience: conf.audience,
  12. clientID: conf.clientId,
  13. clientSecret: conf.clientSecret,
  14. idp: conf.idp,
  15. callbackURL: conf.callbackURL,
  16. response_type: 'code'
  17. }, async (accessToken, refreshToken, profile, cb) => {
  18. try {
  19. const user = await WIKI.models.users.processProfile({
  20. profile: {
  21. ...profile,
  22. picture: _.get(profile, '_json.profile', '')
  23. },
  24. providerKey: 'okta'
  25. })
  26. cb(null, user)
  27. } catch (err) {
  28. cb(err, null)
  29. }
  30. })
  31. )
  32. }
  33. }