How to use the saml.Saml20.create function in saml

To help you get started, we’ve selected a few saml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github auth0 / node-samlp / lib / samlp.js View on Github external
function getSamlResponse(options, user, callback) {
  options.profileMapper = options.profileMapper || PassportProfileMapper;
  options.signatureNamespacePrefix = typeof options.signatureNamespacePrefix === 'string' ? options.signatureNamespacePrefix : '' ;

  var profileMap = options.profileMapper(user);
  var claims = profileMap.getClaims(options);
  var ni = profileMap.getNameIdentifier(options);

  if (!ni || !ni.nameIdentifier) {
    var error = new Error('No attribute was found to generate the nameIdentifier. We tried with: ' + (options.nameIdentifierProbes || []).join(', '));
    error.context = { user: user };
    return callback(error);
  }

  saml20.create({
    signatureAlgorithm:   options.signatureAlgorithm,
    digestAlgorithm:      options.digestAlgorithm,
    cert:                 options.cert,
    key:                  options.key,
    issuer:               options.issuer,
    lifetimeInSeconds:    options.lifetimeInSeconds || 3600,
    audiences:            options.audience,
    attributes:           claims,
    nameIdentifier:       ni.nameIdentifier,
    nameIdentifierFormat: ni.nameIdentifierFormat || options.nameIdentifierFormat,
    recipient:            options.recipient,
    inResponseTo:         options.inResponseTo,
    authnContextClassRef: options.authnContextClassRef,
    encryptionPublicKey:  options.encryptionPublicKey,
    encryptionCert:       options.encryptionCert,
    sessionIndex:         options.sessionIndex,