Code: Select all
const saml = require('samlify');
// configure a service provider
const sp = saml.ServiceProvider({
metadata: fs.readFileSync('./metadata_sp.xml')
});
// configure the corresponding identity provider
const idp = saml.IdentityProvider({
metadata: fs.readFileSync('./metadata_idp.xml')
});
// parse when receive a SAML Response from IdP
router.post('/acs', (req, res) => {
sp.parseLoginResponse(idp, 'post', req)
.then(parseResult => {
// Write your own validation and render function here
})
.catch(console.error);
});