{"id":15046782,"url":"https://github.com/auth0/node-samlp","last_synced_at":"2025-04-08T08:17:48.853Z","repository":{"id":521098,"uuid":"9811293","full_name":"auth0/node-samlp","owner":"auth0","description":"SAML Protocol support for node (only IdP for now)","archived":false,"fork":false,"pushed_at":"2024-04-26T14:01:28.000Z","size":393,"stargazers_count":136,"open_issues_count":38,"forks_count":117,"subscribers_count":108,"default_branch":"master","last_synced_at":"2025-04-01T05:37:42.273Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/auth0.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-05-02T10:57:15.000Z","updated_at":"2024-11-16T02:12:40.000Z","dependencies_parsed_at":"2023-07-05T15:02:08.411Z","dependency_job_id":"f4d291a4-b3f1-4e21-814f-622a6d85be65","html_url":"https://github.com/auth0/node-samlp","commit_stats":{"total_commits":234,"total_committers":43,"mean_commits":5.441860465116279,"dds":0.7905982905982906,"last_synced_commit":"1d72b8034709cbe1ede5a4241cf79ee746026ae3"},"previous_names":[],"tags_count":55,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2Fnode-samlp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2Fnode-samlp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2Fnode-samlp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2Fnode-samlp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/auth0","download_url":"https://codeload.github.com/auth0/node-samlp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247801176,"owners_count":20998339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T20:53:34.513Z","updated_at":"2025-04-08T08:17:48.830Z","avatar_url":"https://github.com/auth0.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"SAML Protocol middleware to create SAMLP identity providers for node.js.\n\n![Build Status](https://github.com/auth0/node-samlp/workflows/Tests/badge.svg)\n\n## Installation\n\n    npm install samlp\n\n### Supported Node Versions\n\nnode \u003e= 12\n\n## Introduction\n\nThis middleware is meant to generate a valid SAML Protocol identity provider endpoint that speaks saml.\n\nThe idea is that you will use another mechanism to validate the user first.\n\nThe endpoint supports metadata as well in the url ```/FederationMetadata/2007-06/FederationMetadata.xml```.\n\n## Login (Authentication Flow)\n\n### Usage\n\nOptions\n\n| Name                | Description                                      | Default                                      |\n| --------------------|:-------------------------------------------------| ---------------------------------------------|\n| cert                | public key used by this identity provider        | REQUIRED                                     |\n| key                 | private key used by this identity provider       | REQUIRED                                     |\n| getPostURL          | get the url to post the token f(audience, samlRequestDom, req, callback)                | REQUIRED                                     |\n| issuer              | the name of the issuer of the token              | REQUIRED                                     |\n| audience            | the audience for the saml token                  | req.query.SAMLRequest.Issuer                 |\n| getUserFromRequest  | how to extract the user information from request | function(req) { return req.user; }           |\n| profileMapper       | mapper to map users to claims (see PassportProfileMapper)| PassportProfileMapper |\n| signatureAlgorithm  | signature algorithm, options: rsa-sha1, rsa-sha256 | ```'rsa-sha256'``` |\n| digestAlgorithm     | digest algorithm, options: sha1, sha256          | ```'sha256'``` |\n| signResponse        | whether to sign the SAML response                | false                                        |\n| signAssertion       | whether to sign the SAML assertion               | true                                         |\n| RelayState          | state of the auth process                        | ```req.query.RelayState || req.body.RelayState``` |\n| sessionIndex          | the index of a particular session between the principal identified by the subject and the authenticating authority                        | _SessionIndex is not included_ |\n| responseHandler       | custom response handler for SAML response f(SAMLResponse, options, req, res, next) | HTML response that POSTS to postUrl |\n\n\nAdd the middleware as follows:\n\n~~~javascript\napp.get('/samlp', samlp.auth({\n  issuer:     'the-issuer',\n  cert:       fs.readFileSync(path.join(__dirname, 'some-cert.pem')),\n  key:        fs.readFileSync(path.join(__dirname, 'some-cert.key')),\n  getPostURL: function (wtrealm, wreply, req, callback) {\n                return callback( null, 'http://someurl.com')\n              }\n}));\n~~~~\n\n## SAML Protocol Metadata\n\nThis module also support generating SAML Protocol metadata (IDPSsoDescriptor):\n\n~~~javascript\napp.get('/samlp/FederationMetadata/2007-06/FederationMetadata.xml', samlp.metadata({\n  issuer:   'the-issuer',\n  cert:     fs.readFileSync(path.join(__dirname, 'some-cert.pem')),\n}));\n~~~\n\nIt also accept two optionals parameters:\n\n-  profileMapper: a class implementing the profile mapper. This is used to render the claims type information (using the metadata property). See [PassportProfileMapper](https://github.com/auth0/node-samlp/blob/master/lib/claims/PassportProfileMapper.js) for more information.\n-  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.```\n\n*Note:* If `x-forwarded-host` or `x-forwarded-proto` are received during the HTTP request to the metadata endpoint the urls contained in the metadata will use those them as host or protocol respectively instead of the original ones from `request.headers.host` and `request.protocol`.\n\n## Logout - SLO (Single Logout)\nStarting on version `v2.0` Single Logout is supported (SAML 2.0 Single Logout Profile). General support for SLO among Session Participants is varies a lot. This module supports the following flows:\n\n- IdP Initiated: a logout is initiated by invoking the GET logout endpoint specified in the IdP metadata. The IdP creates a signed SAML `LogoutRequest` and propagates it to the involved Session Participants.\n- SP Initiated: a Session Participant starts a SLO by sending a SAML `LogoutRequest` to the IdP. The IdP propagates it to the involved Session Participants.\n\nBoth flows need the IdP to accept SAML `LogoutResponses` from the Session Participants. This is also supported by this module.\n\n### Usage\n\nOptions\n\n| Name                | Description                                      | Default                                          |\n| --------------------|:-------------------------------------------------| -------------------------------------------------|\n| cert                | public key used by this identity provider        | REQUIRED                                         |\n| key                 | private key used by this identity provider       | REQUIRED                                         |\n| issuer              | the name of the issuer of the token              | REQUIRED                                         |\n| protocolBinding     | the binding to use                               | 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST' |\n| sessionParticipants | an object that handles Session Participants. Check [this implementation](./lib/sessionParticipants/index.js) | An empty object. It is REQUIRED if you want to use SLO          |\n| clearIdPSession     | a function to be called when the logout process is finished so the IdP can clean its session | function (cb){ return cb(); |\n| store               | an object that handles the HTTP Session. Check [this implementation](./test/in_memory_store/) | new SessionStore(options) Uses req.session to store the current state |\n\n#### Notes\n\n- options.cert: This is the public certificate of the IdP\n- options.key: This is the private key of the IdP. The IdP will sign its SAML `LogoutRequest` and `LogoutResponse` with this key.\n- options.store: Since the logout flow will involve several requests/responses, we need to keep track of the transaction state. The default implementation uses req.session to store the transaction state via the 'flowstate' module\n- options.sessionParticipants: Will handle SessionParticipant objects. Each SessionParticipant object needs to have the following structure:\n\n```js\nvar sessionParticipant = {\n  serviceProviderId : 'https://foobarsupport.zendesk.com', // The Issuer (Session Participant id)\n  nameId: 'foo@example.com', // NameId Of the logged in user in the SP\n  nameIdFormat: 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient', // Format of the NameId\n  sessionIndex: '1', // The session index generated by the IdP\n  serviceProviderLogoutURL: 'https://foobarsupport.zendesk.com/logout', // The logout URL of the Session Participant\n  cert: sp1_credentials.cert, // The Session Participant public certificate, used to verify the signature of the SAML requests made by this SP\n  binding: 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST' // Optional, participant-specific binding to use during SLO, if not provided - will use \"protocolBinding\" from provided options\n};\n```\n\nIn some situations it is possible for session participants to have mixed bindings during one Single Log Out (SLO) transaction. By default the library will use the binding specified in `options.protocolBinding`, however if mixed bindings must be used - each participant must have the binding specified as an additional field. If the binding value is invalid - it will fall back to `HTTP-POST`.\n\nAdd the middleware as follows:\n\n~~~javascript\n  app.get('/logout', samlp.logout({\n      deflate:            true,\n      issuer:             'the-issuer',\n      protocolBinding:    'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',\n      cert:               fs.readFileSync(path.join(__dirname, 'some-cert.pem')),\n      key:                fs.readFileSync(path.join(__dirname, 'some-cert.key'))\n  }));\n\n  app.post('/logout', samlp.logout({\n      issuer:             'the-issuer',\n      protocolBinding:    'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',\n      cert:               fs.readFileSync(path.join(__dirname, 'some-cert.pem')),\n      key:                fs.readFileSync(path.join(__dirname, 'some-cert.key'))\n  }));\n~~~~\n\n## Error handling\n\nErrors are not sent back to the SP. To do so, you'll need to use the `sendError` middleware.\n\n~~~javascript\nsamlp.sendError({\n    RelayState:         'relayState',\n    issuer:             'the-issuer',\n    signatureAlgorithm: 'rsa-sha1',\n    digestAlgorithm:    'sha1',\n    cert:               fs.readFileSync(path.join(__dirname, 'some-cert.pem')),\n    key:                fs.readFileSync(path.join(__dirname, 'some-cert.key')),\n    error: { description: err.message },\n    getPostURL: function (req, callback) {\n      callback(null, 'http://someurl.com');\n    }\n})(req, res, next);\n~~~~\n\n## Issue Reporting\n\nIf you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues.\n\n## Author\n\n[Auth0](auth0.com)\n\n## License\n\nThis project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauth0%2Fnode-samlp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fauth0%2Fnode-samlp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauth0%2Fnode-samlp/lists"}