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.

34 lines
950 B

  1. /* global WIKI */
  2. // ------------------------------------
  3. // Auth0 Account
  4. // ------------------------------------
  5. const Auth0Strategy = require('passport-auth0').Strategy
  6. module.exports = {
  7. init (passport, conf) {
  8. passport.use(conf.key,
  9. new Auth0Strategy({
  10. domain: conf.domain,
  11. clientID: conf.clientId,
  12. clientSecret: conf.clientSecret,
  13. callbackURL: conf.callbackURL,
  14. passReqToCallback: true
  15. }, async (req, accessToken, refreshToken, extraParams, profile, cb) => {
  16. try {
  17. const user = await WIKI.models.users.processProfile({
  18. providerKey: req.params.strategy,
  19. profile
  20. })
  21. cb(null, user)
  22. } catch (err) {
  23. cb(err, null)
  24. }
  25. }
  26. ))
  27. },
  28. logout (conf) {
  29. return `https://${conf.domain}/v2/logout?${new URLSearchParams({ client_id: conf.clientId, returnTo: WIKI.config.host }).toString()}`
  30. }
  31. }