# feathers-authentication-custom

> Custom authentication strategy for feathers-authentication using Passport

Latest version **0.1.0** (published 2017-11-02) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install feathers-authentication-custom
pnpm add feathers-authentication-custom
yarn add feathers-authentication-custom
bun add feathers-authentication-custom
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2017-11-02 |
| First published | 2017-11-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 6 |
| Dependencies | 5 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Ryan Wheale |
| Maintainers | daffl |
| Keywords | feathers, feathers-plugin |

## Links

- npm: https://www.npmjs.com/package/feathers-authentication-custom
- npm.io page: https://npm.io/package/feathers-authentication-custom

## Dependencies (5)

- [debug](https://npm.io/package/debug.md) ^3.1.0
- [lodash.omit](https://npm.io/package/lodash.omit.md) ^4.5.0
- [lodash.pick](https://npm.io/package/lodash.pick.md) ^4.4.0
- [lodash.merge](https://npm.io/package/lodash.merge.md) ^4.6.0
- [passport-custom](https://npm.io/package/passport-custom.md) ^1.0.5

## Alternatives

- [@fortawesome/react-fontawesome](https://npm.io/package/@fortawesome/react-fontawesome.md) — 2.2M weekly downloads
- [roboto-fontface](https://npm.io/package/roboto-fontface.md) — 196.0K weekly downloads
- [@react-native-vector-icons/common](https://npm.io/package/@react-native-vector-icons/common.md) — 150.4K weekly downloads
- [@procore/core-icons](https://npm.io/package/@procore/core-icons.md) — 4.6K weekly downloads
- [@react-md/material-icons](https://npm.io/package/@react-md/material-icons.md) — 1.6K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2017-11-02

## README

# feathers-authentication-custom

[![Greenkeeper badge](https://badges.greenkeeper.io/feathersjs-ecosystem/feathers-authentication-custom.svg)](https://greenkeeper.io/)
[![Build Status](https://travis-ci.org/feathersjs-ecosystem/feathers-authentication-custom.png?branch=master)](https://travis-ci.org/feathersjs-ecosystem/feathers-authentication-custom)
[![Maintainability](https://api.codeclimate.com/v1/badges/2a19498748e3f10183e0/maintainability)](https://codeclimate.com/github/feathersjs-ecosystem/feathers-authentication-custom/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/2a19498748e3f10183e0/test_coverage)](https://codeclimate.com/github/feathersjs-ecosystem/feathers-authentication-custom/test_coverage)
[![Dependency Status](https://img.shields.io/david/feathersjs-ecosystem/feathers-authentication-custom.svg?style=flat-square)](https://david-dm.org/feathersjs-ecosystem/feathers-authentication-custom)
[![Download Status](https://img.shields.io/npm/dm/feathersjs-ecosystem/feathers-authentication-custom.svg?style=flat-square)](https://www.npmjs.com/package/feathers-authentication-custom)

> Custom authentication strategy for feathers-authentication using Passport

## Installation

```
npm install feathers-authentication-custom --save
```

## API

This module is a wrapper around the [passport-custom](https://www.npmjs.com/package/passport-custom) strategy which allows you implement a custom verifier function for authenticating requests. 

### Main Initialization

In most cases initializing the `feathers-authentication-custom` module is as simple as doing this:

```js
app.configure(authentication(settings));
app.configure(custom((req, done) => {
	// implement your own custom logic for loading and verifying the user
	done(null, user);
}));
```

If you use a function declaration instead of an arrow `=>` function, then you can use `this.app` to get a reference to the app object:

```js
function verifier (req, done) {
	this.app === app; //-> true
}
app.configure(authentication(settings));
app.configure(custom(verifier));
```

### Verifier class

In more advanced scenarios you can use a Verifier class. This should be familiar to you if you have ever used a custom verifier class with other passport strategies. The class should implement the following methods:

```js
class CustomVerifier {
    constructor(app, options) {} // the class constructor
    verify(req, done) {} // performs custom verification
};

app.configure(authentication(settings));
app.configure(custom({ Verifier: CustomVerifier }));
```

## Expected Request Data
By default, this strategy expects a payload in this format:

```js
{
  strategy: 'custom'
}
```

## Complete Example

Here's a basic example of a Feathers server that uses `feathers-authentication-jwt`. You can see a fully working example in the [example/](./example/) directory.

```js
const feathers = require('feathers');
const rest = require('feathers-rest');
const hooks = require('feathers-hooks');
const memory = require('feathers-memory');
const bodyParser = require('body-parser');
const errorHandler = require('feathers-errors/handler');
const auth = require('feathers-authentication');
const custom = require('feathers-authentication-custom');

function verifier (req, done) {
  // perform custom verifications
  done(null, user);
}

// Initialize the application
const app = feathers()
  .configure(rest())
  .configure(hooks())
  // Needed for parsing bodies (login)
  .use(bodyParser.json())
  .use(bodyParser.urlencoded({ extended: true }))
  // Configure feathers-authentication
  .configure(auth({ secret: 'super secret' }))
  .configure(custom(verifier))
  .use('/users', memory())
  .use(errorHandler());

app.listen(3030);

console.log('Feathers app started on 127.0.0.1:3030');
```

## License

Copyright (c) 2016

Licensed under the [MIT license](LICENSE).

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