/ezpass

Dead simple password protection middleware

Primary LanguageTypeScript

ezpass

Dead simple password protection middleware

Usage

import { createAuthMiddleware } from 'ezpass'
import express from 'express'

const app = express()

app.use(createAuthMiddleware({
  provider: 'basic',
  username: 'test',
  password: 'test'
}))

app.use((_req, res) => { res.end(`Welcome ${req.auth.session.user}!`) })

app.listen(3000)

Options

  • provider
  • providerOptions
  • sessionSecret
  • bypass
  • onAuthorize
  • unauthorizedTemplate

Providers

basic

Options:

  • username
  • password

Example:

app.use(createAuthMiddleware({
  provider: 'basic',
  username: 'test',
  password: 'test'
}))

github

Options:

  • clientId
  • clientSecret

Example:

app.use(createAuthMiddleware({
  provider: 'github',
  sessionSecret: '...',
  clientId: '...',
  clientSecret: '...',
}))

Development

  • Clone Repository
  • Install dependencies with yarn install
  • Use yarn dev test/basic to start basic example

License

MIT