1.1.7 • Published 2 years ago

http-auth-koa v1.1.7

Weekly downloads
1
License
MIT
Repository
github
Last release
2 years ago

http-auth-koa

Koa framework integration with http-auth module.

build

Installation

Via git (or downloaded tarball):

$ git clone git://github.com/http-auth/http-auth-koa.git

Via npm:

$ npm install http-auth-koa

Usage

// Authentication module.
const auth = require("http-auth");
const koaAuth = require("http-auth-koa");

const basic = auth.basic({
  realm: "Simon Area.",
  file: __dirname + "/../data/users.htpasswd"
});

// Koa setup.
const Koa = require("koa");
const app = new Koa();

// Setup basic handler.
app.use(async (ctx, next) => {
  await next();
  ctx.body = `Welcome to koa ${ctx.req.user}!`;
});

// Setup auth.
app.use(koaAuth(basic));

// Start server.
app.listen(1337, function() {
  // Log URL.
  console.log("Server running at http://127.0.0.1:1337/");
});

Running tests

It uses mocha, so just run following command in package directory:

$ npm test

License

The MIT License (MIT)

1.1.7

2 years ago

1.1.6

3 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.1

8 years ago

1.0.0

8 years ago