plug-auth-server
v1.1.2
Published
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.
Downloads
3
Readme
plug-auth-server
Installation
npm install --save plug-auth-server
Usage
See the example app for a more in-depth example.
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
.
import { authenticator, authRoute } from 'plug-auth-server'
const engine = authenticator({ ...options })
const app = express()
app.use('/plug-auth', authRoute(engine))