{"id":28076697,"url":"https://github.com/jaredhanson/passport-strategy","last_synced_at":"2025-05-13T01:47:19.681Z","repository":{"id":57320314,"uuid":"11826773","full_name":"jaredhanson/passport-strategy","owner":"jaredhanson","description":"An abstract class implementing Passport's strategy API.","archived":false,"fork":false,"pushed_at":"2018-01-04T16:54:44.000Z","size":12,"stargazers_count":116,"open_issues_count":9,"forks_count":29,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-05T13:13:34.626Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Makefile","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/jaredhanson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-08-01T20:20:44.000Z","updated_at":"2025-05-01T08:20:30.000Z","dependencies_parsed_at":"2022-08-25T20:00:43.527Z","dependency_job_id":null,"html_url":"https://github.com/jaredhanson/passport-strategy","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fpassport-strategy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fpassport-strategy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fpassport-strategy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fpassport-strategy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaredhanson","download_url":"https://codeload.github.com/jaredhanson/passport-strategy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253391743,"owners_count":21900954,"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":"2025-05-13T01:47:16.383Z","updated_at":"2025-05-13T01:47:19.676Z","avatar_url":"https://github.com/jaredhanson.png","language":"Makefile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# passport-strategy\n\n[![Build](https://travis-ci.org/jaredhanson/passport-strategy.png)](https://travis-ci.org/jaredhanson/passport-strategy)\n[![Coverage](https://coveralls.io/repos/jaredhanson/passport-strategy/badge.png)](https://coveralls.io/r/jaredhanson/passport-strategy)\n[![Quality](https://codeclimate.com/github/jaredhanson/passport-strategy.png)](https://codeclimate.com/github/jaredhanson/passport-strategy)\n[![Dependencies](https://david-dm.org/jaredhanson/passport-strategy.png)](https://david-dm.org/jaredhanson/passport-strategy)\n[![Tips](http://img.shields.io/gittip/jaredhanson.png)](https://www.gittip.com/jaredhanson/)\n\n\nAn abstract class implementing [Passport](http://passportjs.org/)'s strategy\nAPI.\n\n## Install\n\n    $ npm install passport-strategy\n\n## Usage\n\nThis module exports an abstract `Strategy` class that is intended to be\nsubclassed when implementing concrete authentication strategies.  Once\nimplemented, such strategies can be used by applications that utilize Passport\nmiddleware for authentication.\n\n#### Subclass Strategy\n\nCreate a new `CustomStrategy` constructor which inherits from `Strategy`:\n\n```javascript\nvar util = require('util')\n  , Strategy = require('passport-strategy');\n\nfunction CustomStrategy(...) {\n  Strategy.call(this);\n}\n\nutil.inherits(CustomStrategy, Strategy);\n```\n\n#### Implement Authentication\n\nImplement `autheticate()`, performing the necessary operations required by the\nauthentication scheme or protocol being implemented.\n\n```javascript\nCustomStrategy.prototype.authenticate = function(req, options) {\n  // TODO: authenticate request\n}\n```\n\n#### Augmented Methods\nThe Strategy.authenticate method is called on an instance of this Strategy that's augmented with the following action functions.  \nThese action functions are bound via closure the the request/response pair.  \nThe end goal of the strategy is to invoke *one* of these action methods, in\norder to indicate successful or failed authentication, redirect to a\nthird-party identity provider, etc.\n\n* [.success(user, info)](#Strategy+success)\n* [.fail(challenge, status)](#Strategy+fail)\n* [.redirect(url, status)](#Strategy+redirect)\n* [.pass()](#Strategy+pass)\n* [.error(err)](#Strategy+error)\n\n\n##### strategy.success(user, info)\nAuthenticate `user`, with optional `info`.\n\nStrategies should call this function to successfully authenticate a\nuser.  `user` should be an object supplied by the application after it\nhas been given an opportunity to verify credentials.  `info` is an\noptional argument containing additional user information.  This is\nuseful for third-party authentication strategies to pass profile\ndetails.\n\n**Kind**: instance method of [Strategy](#Strategy)  \n**Api**: public  \n\n| Param | Type |\n| --- | --- |\n| user | Object | \n| info | Object | \n\n\n##### strategy.fail(challenge, status)\nFail authentication, with optional `challenge` and `status`, defaulting\nto 401.\n\nStrategies should call this function to fail an authentication attempt.\n\n**Kind**: instance method of [Strategy](#Strategy)  \n**Api**: public  \n\n| Param | Type |\n| --- | --- |\n| challenge | String | \n| status | Number | \n\n\n\n##### strategy.redirect(url, status)\nRedirect to `url` with optional `status`, defaulting to 302.\n\nStrategies should call this function to redirect the user (via their\nuser agent) to a third-party website for authentication.\n\n**Kind**: instance method of [Strategy](#Strategy)  \n**Api**: public  \n\n| Param | Type |\n| --- | --- |\n| url | String | \n| status | Number | \n\n\n##### strategy.pass()\nPass without making a success or fail decision.\n\nUnder most circumstances, Strategies should not need to call this\nfunction.  It exists primarily to allow previous authentication state\nto be restored, for example from an HTTP session.\n\n**Kind**: instance method of [Strategy](#Strategy)  \n**Api**: public  \n\n##### strategy.error(err)\nInternal error while performing authentication.\n\nStrategies should call this function when an internal error occurs\nduring the process of performing authentication; for example, if the\nuser directory is not available.\n\n**Kind**: instance method of [Strategy](#Strategy)  \n**Api**: public  \n\n| Param | Type |\n| --- | --- |\n| err | Error | \n\n\n\n## Related Modules\n\n- [chai-passport-strategy](https://github.com/jaredhanson/chai-passport-strategy) — helpers for testing strategies with the Chai assertion library\n\n## Tests\n\n    $ npm install\n    $ npm test\n\n## Credits\n\n  - [Jared Hanson](http://github.com/jaredhanson)\n\n## License\n\n[The MIT License](http://opensource.org/licenses/MIT)\n\nCopyright (c) 2011-2014 Jared Hanson \u003c[http://jaredhanson.net/](http://jaredhanson.net/)\u003e\n\n\u003ca target='_blank' rel='nofollow' href='https://app.codesponsor.io/link/vK9dyjRnnWsMzzJTQ57fRJpH/jaredhanson/passport-strategy'\u003e  \u003cimg alt='Sponsor' width='888' height='68' src='https://app.codesponsor.io/embed/vK9dyjRnnWsMzzJTQ57fRJpH/jaredhanson/passport-strategy.svg' /\u003e\u003c/a\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredhanson%2Fpassport-strategy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaredhanson%2Fpassport-strategy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredhanson%2Fpassport-strategy/lists"}