Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as samlp from 'samlp';
// Example
const app = express();
app.get('/samlp', samlp.auth({
issuer: 'the-issuer',
cert: fs.readFileSync(path.join(__dirname, 'some-cert.pem')),
key: fs.readFileSync(path.join(__dirname, 'some-cert.key')),
getPostURL: function (wtrealm, wreply, req, cb) {
return cb( null, 'http://someurl.com')
}
}));
app.get('/samlp/FederationMetadata/2007-06/FederationMetadata.xml', samlp.metadata({
issuer: 'the-issuer',
cert: fs.readFileSync(path.join(__dirname, 'some-cert.pem')),
}));
app.use((req: express.Request, res: express.Response, next: express.NextFunction) => {
samlp.parseRequest(req, (err: any, data: any) => {
next();
});
});
res.body(error.message);
res.end();
console.error(error);
}
} else {
// continue with issuing token using samlp
next();
}
} else {
res.send("go away!");
res.end();
}
});
app.get("/issue/", samlp.auth(samlpoptions));
app.get("/issue/FederationMetadata/2007-06/FederationMetadata.xml", samlp.metadata({
issuer: Config.saml_issuer,
cert: cert,
}));
// var SessionParticipants = require('samlp/lib/sessionParticipants');
// https://github.com/mcguinness/saml-idp/blob/master/app.js
// https://www.diycode.cc/projects/auth0/node-samlp
// https://github.com/auth0/node-samlp/blob/master/lib/sessionParticipants/index.js
// app.get('/logout', samlp.logout({
// deflate: true,
// issuer: 'the-issuer',
// protocolBinding: 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
// cert: cert,
// key: key
// }));
app.get(IDP_PATHS.METADATA, function(req, res, next) {
samlp.metadata(req.idp.options)(req, res);
});