let fs = require("fs"), passport = require("passport"), SamlStrategy = require("passport-saml").Strategy; passport.serializeUser(function (user, done) { done(null, user); }); passport.deserializeUser(function (user, done) { done(null, user); }); passport.use( new SamlStrategy( { entryPoint: "https://sso.satitm.chula.ac.th/adfs/ls", issuer: "https://localhost:3000", callbackUrl: "https://localhost:3000/selfservice/activedirectory/postResponse", privateKey: fs.readFileSync("adfs_connect/urn_satitm_sso_selfservice.key", "utf-8"), acceptedClockSkewMs: -1, identifierFormat: null, signatureAlgorithm: "sha256", racComparison: "exact", }, function (profile, done) { console.log("profile", profile); let user = profile["http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn"]; return done(null, { upn: profile["http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn"], // e.g. if you added a Group claim group: profile["http://schemas.xmlsoap.org/claims/Group"], }); } ) ); module.exports = passport;