SAML Protocol server middleware

npm install samlp
60 downloads in the last week
169 downloads in the last month

SAML Protocol middleware to create SAMLP identity providers for node.js.

Build Status


npm install samlp


This middleware is meant to generate a valid SAML Protocol identity provider endpoint that speaks saml.

The idea is that you will use another mechanism to validate the user first.

The endpoint supports metadata as well in the url /FederationMetadata/2007-06/FederationMetadata.xml.



Name Description Default
cert public key used by this identity provider REQUIRED
key private key used by this identity provider REQUIRED
getPostURL get the url to post the token f(audience, samlRequestDom, req, callback) REQUIRED
issuer the name of the issuer of the token REQUIRED
audience the audience for the saml token req.query.SAMLRequest.Issuer
getUserFromRequest how to extract the user information from request function(req) { return req.user; }
profileMapper mapper to map users to claims (see PassportProfileMapper) PassportProfileMapper
signatureAlgorithm signature algorithm, options: rsa-sha1, rsa-sha256 'rsa-sha256'
digestAlgorithm digest algorithm, options: sha1, sha256 'sha256'
RelayState state of the auth process ```req.query.RelayState req.body.RelayState```

Add the middleware as follows:

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, callback) { 
                return cb( null, '')

SAML Protocol Metadata

This module also support generating SAML Protocol metadata (IDPSsoDescriptor):

app.get('/samlp/FederationMetadata/2007-06/FederationMetadata.xml', wsfed.metadata({
  issuer:   'the-issuer',
  cert:     fs.readFileSync(path.join(__dirname, 'some-cert.pem')),

It also accept two optionals parameters:

  • profileMapper: a class implementing the profile mapper. This is used to render the claims type information (using the metadata property). See PassportProfileMapper for more information.
  • endpointPath: this is the full path in your server to the auth route. By default the metadata handler uses the metadata request route without /FederationMetadata/2007..blabla.


MIT - AUTH0 2013!

npm loves you