# http-auth-koa

> Koa framework integration with http-auth module.

Latest version **1.1.7** (published 2022-09-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install http-auth-koa
pnpm add http-auth-koa
yarn add http-auth-koa
bun add http-auth-koa
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.7 |
| Published | 2022-09-21 |
| First published | 2016-06-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 0 |
| Unpacked size | 3.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Gevorg Harutyunyan |
| Maintainers | gevorg |
| Keywords | koa, http, basic, digest, access, authentication |

## Links

- npm: https://www.npmjs.com/package/http-auth-koa
- Repository: https://github.com/http-auth/http-auth-koa
- Issues: http://github.com/http-auth/http-auth-koa/issues
- npm.io page: https://npm.io/package/http-auth-koa

## Alternatives

- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads
- [escher-request](https://npm.io/package/escher-request.md) — 545 weekly downloads

## Recent versions

- 1.1.7 (latest) — 2022-09-21
- 1.1.6 — 2021-06-24
- 1.1.5 — 2020-02-03
- 1.1.4 — 2020-02-03
- 1.1.3 — 2020-02-02
- 1.1.2 — 2020-02-02
- 1.1.1 — 2020-02-02
- 1.1.0 — 2020-02-02
- 1.0.1 — 2016-06-18
- 1.0.0 — 2016-06-17

## README

# http-auth-koa
[Koa framework](http://koajs.com/) integration with [http-auth](https://github.com/gevorg/http-auth) module.

[![build](https://github.com/http-auth/http-auth-koa/workflows/build/badge.svg)](https://github.com/http-auth/http-auth-koa/actions/workflows/build.yml)

## Installation

Via git (or downloaded tarball):

```bash
$ git clone git://github.com/http-auth/http-auth-koa.git
```
Via [npm](http://npmjs.org/):

```bash
$ npm install http-auth-koa
```    

## Usage
```javascript
// 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](https://mochajs.org/), so just run following command in package directory:

```bash
$ npm test
```

## License

The MIT License (MIT)

---
_Source: https://npm.io/package/http-auth-koa · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
