# passport-lead-auth

> Lead Auth authentication strategy for Passport.

Latest version **0.0.6** (published 2016-06-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install passport-lead-auth
pnpm add passport-lead-auth
yarn add passport-lead-auth
bun add passport-lead-auth
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2016-06-09 |
| First published | 2016-05-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.4.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Kurakin Oleksandr |
| Maintainers | lead-auth |
| Keywords | passport, lead-auth, auth, authentication, identity, oauth2 |

## Links

- npm: https://www.npmjs.com/package/passport-lead-auth
- Repository: https://github.com/lead-auth/passport-lead-auth
- Homepage: https://github.com/lead-auth/passport-lead-auth#readme
- Issues: http://github.com/lead-auth/passport-lead-auth/issues
- npm.io page: https://npm.io/package/passport-lead-auth

## Dependencies (1)

- [passport-oauth2](https://npm.io/package/passport-oauth2.md) ^1.3.0

## Alternatives

- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads
- [escher-request](https://npm.io/package/escher-request.md) — 545 weekly downloads

## Recent versions

- 0.0.6 (latest) — 2016-06-09
- 0.0.5 — 2016-05-17
- 0.0.4 — 2016-05-16
- 0.0.3 — 2016-05-16
- 0.0.2 — 2016-05-16
- 0.0.1 — 2016-05-16

## README

# passport-lead-auth


[Passport](http://passportjs.org/) strategy for authenticating with [Lead-Auth](https://lead-auth.com/)

This module lets you authenticate using Lead Auth in your Node.js applications.
By plugging into Passport, Lead Auth authentication can be easily and
unobtrusively integrated into any application or framework that supports
[Connect](http://www.senchalabs.org/connect/)-style middleware, including
[Express](http://expressjs.com/).

## Install

    $ npm install passport-lead-auth

## Usage

#### Create an Application

Before using `passport-lead-auth`, you must register an application with
Lead Auth.  If you have not already done so, a new application can be created at
[Lead Auth](https://lead-auth.com/).  Your application will
be issued an app ID and app secret, which need to be provided to the strategy.
You will also need to configure a redirect URI which matches the route in your
application.

#### Configure Strategy

The Lead Auth authentication strategy authenticates users using a Lead Auth
account and OAuth 2.0 tokens.  The app ID and secret obtained when creating an
application are supplied as options when creating the strategy.  The strategy
also requires a `verify` callback, which receives the access token and optional
refresh token, as well as `profile` which contains the authenticated user's 
profile.  The `verify` callback must call `cb` providing a user to
complete authentication.

```js
passport.use(new LeadAuthStrategy({
    account: LEAD_AUTH_ACCOUNT,
    clientID: LEAD_AUTH_APP_ID,
    clientSecret: LEAD_AUTH_APP_SECRET,
    callbackURL: "http://localhost/auth/lead-auth/callback"
  },
  function(accessToken, refreshToken, profile, cb) {
    User.findOrCreate({ leadAuthId: profile.id }, function (err, user) {
      return cb(err, user);
    });
  }
));
```

#### Authenticate Requests

Use `passport.authenticate()`, specifying the `'lead-auth'` strategy, to
authenticate requests.

For example, as route middleware in an [Express](http://expressjs.com/)
application:

```js
app.get('/auth/lead-auth',
  passport.authenticate('lead-auth'));

app.get('/auth/lead-auth/callback',
  passport.authenticate('lead-auth', { failureRedirect: '/login' }),
  function(req, res) {
    // Successful authentication, redirect home.
    res.redirect('/');
  });
```


## Contributing

#### Tests

The test suite is located in the `test/` directory.  All new features are expected to have corresponding test cases.  Ensure that the complete test suite passes by executing:

```
npm test
```

## Issue Reporting

If you have found a bug or if you have a feature request, please report them at this repository issues section.

## Author

[Lead Auth](https://lead-auth.com/)

## License

This project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info.

---
_Source: https://npm.io/package/passport-lead-auth · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
