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.

29 lines
674 B

  1. /* global WIKI */
  2. // ------------------------------------
  3. // CAS Account
  4. // ------------------------------------
  5. const CASStrategy = require('passport-cas').Strategy
  6. module.exports = {
  7. init (passport, conf) {
  8. passport.use('cas',
  9. new CASStrategy({
  10. ssoBaseURL: conf.ssoBaseURL,
  11. serverBaseURL: conf.serverBaseURL,
  12. passReqToCallback: true
  13. }, async (req, profile, cb) => {
  14. try {
  15. const user = await WIKI.models.users.processProfile({
  16. providerKey: req.params.strategy,
  17. profile
  18. })
  19. cb(null, user)
  20. } catch (err) {
  21. cb(err, null)
  22. }
  23. })
  24. )
  25. }
  26. }