Home

Awesome

Koa Context Basic Auth

NPM version Build status Test coverage Greenkeeper badge Dependency Status License Downloads

Augments Koa with const { name, pass } = ctx.basicAuth and ctx.request.basicAuth.

Example

const Koa = require('koa')

const app = new Koa()

require('koa-ctx-basic-auth')(app)

app.use(async (ctx, next) => {
  const { name, pass } = ctx.basicAuth
  // OR
  const { name, pass } = ctx.request.basicAuth

  await next()
})