{"id":18821157,"url":"https://github.com/compwright/passport-compose","last_synced_at":"2026-01-17T21:30:22.327Z","repository":{"id":52087024,"uuid":"145136825","full_name":"compwright/passport-compose","owner":"compwright","description":"Utilities for chaining multiple Passport authentication middlewares","archived":false,"fork":false,"pushed_at":"2023-07-18T21:16:58.000Z","size":164,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-30T09:02:53.006Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/passport-compose","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/compwright.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"compwright"}},"created_at":"2018-08-17T15:25:02.000Z","updated_at":"2023-02-13T18:14:56.000Z","dependencies_parsed_at":"2024-11-08T00:35:57.367Z","dependency_job_id":"1e6f1a18-097b-4457-9d20-afe94597743d","html_url":"https://github.com/compwright/passport-compose","commit_stats":{"total_commits":27,"total_committers":3,"mean_commits":9.0,"dds":0.2592592592592593,"last_synced_commit":"1ed9c11ae93fa86c3d13f5877e854cfe2fd6835b"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compwright%2Fpassport-compose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compwright%2Fpassport-compose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compwright%2Fpassport-compose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compwright%2Fpassport-compose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/compwright","download_url":"https://codeload.github.com/compwright/passport-compose/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239758831,"owners_count":19692034,"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-11-08T00:34:52.421Z","updated_at":"2025-02-20T00:46:45.674Z","avatar_url":"https://github.com/compwright.png","language":"JavaScript","funding_links":["https://github.com/sponsors/compwright"],"categories":[],"sub_categories":[],"readme":"# passport-compose\n\n[![Dependency Status](https://img.shields.io/david/compwright/passport-compose.svg?style=flat-square)](https://david-dm.org/compwright/passport-compose)\n[![Download Status](https://img.shields.io/npm/dm/passport-compose.svg?style=flat-square)](https://www.npmjs.com/package/passport-compose)\n[![Sponsor on GitHub](https://img.shields.io/static/v1?label=Sponsor\u0026message=❤\u0026logo=GitHub\u0026link=https://github.com/sponsors/compwright)](https://github.com/sponsors/compwright)\n\nUtilities for chaining multiple Passport authentication middlewares\n\n## Use case\n\nYou have multiple Passport authentication strategies, and you need _all_ of them to run before considering the user to be authenticated.\n\nFor instance, you may wish to authenticate with username and password (via passport-local), then also pass an OTP or CAPTCHA check in a separate strategy.\n\n## Requirements\n\n* Node.js 8+\n* Passport strategies of your choice\n\n## Installation\n\n```bash\n$ npm install --save passport-compose\n```\n\n## Usage\n\n```javascript\nconst passportCompose = require(\"passport-compose\");\nconst { compose, loginRedirect, isAuthenticated } = passportCompose({\n  // optional configuration\n  sessionStageField: \"passport.stage\",\n  sessionLoginRedirectField: \"redirectTo\",\n  successRedirect: \"/\",\n  successReturnToOrRedirect: \"/\",\n  failureRedirect: \"/login\"\n});\n\n// This example assumes you have set up an express application called \"app\",\n// and have required and configured \"local\" and \"otp\" strategies for passport\n\n// Do not set \"successRedirect\" or \"successReturnToOrRedirect\" here, or a\n// passing strategy will redirect before the next one runs\nconst localSettings = { failureRedirect: \"/login\" };\nconst otpSettings = { failureRedirect: \"/login\" };\n\n// Require successful username+password and OTP authentication, then redirect\nconst strategies = [\n  passport.authenticate(\"local\", localSettings)),\n  passport.authenticate(\"otp\", otpSettings))\n];\napp.post(\"/login\", compose(strategies), loginRedirect());\n\n// To require all strategies to pass before accessing a resource:\napp.get(\"/protected\", isAuthenticated(), (req, res) =\u003e {\n  res.sendStatus(204);\n});\n```\n\n## License\n\nMIT license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompwright%2Fpassport-compose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcompwright%2Fpassport-compose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompwright%2Fpassport-compose/lists"}