1.0.2 • Published 7 years ago

koa-http-basic-auth v1.0.2

Weekly downloads
36
License
MIT
Repository
github
Last release
7 years ago

koa-http-basic-auth Build Status

Installation

npm

npm install --save koa-http-basic-auth

yarn

yarn add koa-http-basic-auth

Usage

const Koa = require('koa');
const basicAuth = require('koa-http-basic-auth');

const app = new Koa();

// Register koa-http-basic-auth middleware
app.use(basicAuth({
  user: 'username', // required
  pass: 'password', // required
  realm: 'Authorization', // optional, defaults to 'Authorization required'
}));

// Protected response
app.use(async (ctx) => {
  ctx.status(200);
  ctx.body = 'Protected';
});

app.listen(3000);
1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago