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.

40 lines
1.2 KiB

  1. const _ = require('lodash')
  2. /* global WIKI */
  3. // ------------------------------------
  4. // SAML Account
  5. // ------------------------------------
  6. const SAMLStrategy = require('passport-saml').Strategy
  7. module.exports = {
  8. init (passport, conf) {
  9. passport.use('saml',
  10. new SAMLStrategy({
  11. callbackURL: conf.callbackURL,
  12. entryPoint: conf.entryPoint,
  13. issuer: conf.issuer,
  14. audience: conf.audience,
  15. cert: _.split(conf.cert, '|'),
  16. privateCert: conf.privateCert,
  17. decryptionPvk: conf.decryptionPvk,
  18. signatureAlgorithm: conf.signatureAlgorithm,
  19. identifierFormat: conf.identifierFormat,
  20. acceptedClockSkewMs: _.toSafeInteger(conf.acceptedClockSkewMs),
  21. disableRequestedAuthnContext: conf.disableRequestedAuthnContext,
  22. authnContext: conf.authnContext,
  23. forceAuthn: conf.forceAuthn,
  24. providerName: conf.providerName,
  25. skipRequestCompression: conf.skipRequestCompression,
  26. authnRequestBinding: conf.authnRequestBinding
  27. }, (profile, cb) => {
  28. WIKI.models.users.processProfile(profile).then((user) => {
  29. return cb(null, user) || true
  30. }).catch((err) => {
  31. return cb(err, null) || true
  32. })
  33. })
  34. )
  35. }
  36. }