Dead simple password protection middleware
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)
provider
providerOptions
sessionSecret
bypass
onAuthorize
unauthorizedTemplate
Options:
username
password
Example:
app.use(createAuthMiddleware({
provider: 'basic',
username: 'test',
password: 'test'
}))
Options:
clientId
clientSecret
Example:
app.use(createAuthMiddleware({
provider: 'github',
sessionSecret: '...',
clientId: '...',
clientSecret: '...',
}))
- Clone Repository
- Install dependencies with
yarn install
- Use
yarn dev test/basic
to start basic example
MIT