# plug-auth-server

> Client- and server-side library for "authenticating" plug.dj users to your service. Sort of like third-party OAuth for plug.dj, but not OAuth.

Latest version **1.1.2** (published 2017-07-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install plug-auth-server
pnpm add plug-auth-server
yarn add plug-auth-server
bun add plug-auth-server
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2017-07-10 |
| First published | 2016-09-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 (+5 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Renée Kooi |
| Maintainers | goto-bus-stop |
| Keywords | plug, plug.dj, login |

## Links

- npm: https://www.npmjs.com/package/plug-auth-server
- Repository: https://github.com/goto-bus-stop/plug-auth
- Homepage: https://github.com/goto-bus-stop/plug-auth#readme
- Issues: https://github.com/goto-bus-stop/plug-auth/issues
- npm.io page: https://npm.io/package/plug-auth-server

## Dependencies (7)

- [got](https://npm.io/package/got.md) ^7.1.0
- [pify](https://npm.io/package/pify.md) ^3.0.0
- [cookie](https://npm.io/package/cookie.md) ^0.3.1
- [plug-login](https://npm.io/package/plug-login.md) ^1.1.1
- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) ^7.1.9
- [promise-props](https://npm.io/package/promise-props.md) ^1.0.0
- [random-string](https://npm.io/package/random-string.md) ^0.2.0

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 1.1.2 (latest) — 2017-07-10
- 1.1.1 — 2017-03-24
- 1.1.0 — 2016-12-28
- 1.0.0 — 2016-09-20

## README

# plug-auth-server

## Installation

```bash
npm install --save plug-auth-server
```

## Usage

See the [example app] for a more in-depth example.

```js
import * as fs from 'fs'
import express from 'express'
import {
  authenticator,
  authRoute
} from 'plug-auth-server'

const secret = fs.readFileSync('./secret.dat')

const engine = authenticator({
  auth: userAccount,
  secret: secret
})

const app = express()
app.use('/plug-auth', authRoute(engine))
```

## API

### authenticator(options: object)

Options:

 - `auth`: Login details for a [plug.dj] account. This account will be used for
   the requests needed to verify a [plug.dj] user.

   - `auth.email`: Email address.
   - `auth.password`: Password.

 - `secret`: Key used to sign authentication tokens.
 - `users`: Optional - a user repository instance.

### authRoute(authenticator: object)

Create an express/koa-style route handler for the authentication endpoint. Works
well together with plug-auth-client's [`httpTransport`][httpTransport].

```js
import { authenticator, authRoute } from 'plug-auth-server'
const engine = authenticator({ ...options })
const app = express()
app.use('/plug-auth', authRoute(engine))
```

## License

[MIT]

[plug.dj]: https://plug.dj/
[example app]: ./example/app.js
[httpTransport]: ../plug-auth-client#httpTransport
[MIT]: ./LICENSE

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