https://github.com/baptistelambert/koa-http-basic-auth
🌱 HTTP basic auth middleware for koa.
https://github.com/baptistelambert/koa-http-basic-auth
basic-authentication http koa middleware nodejs
Last synced: 5 months ago
JSON representation
🌱 HTTP basic auth middleware for koa.
- Host: GitHub
- URL: https://github.com/baptistelambert/koa-http-basic-auth
- Owner: baptistelambert
- License: mit
- Created: 2017-10-10T14:09:24.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-13T12:46:55.000Z (over 8 years ago)
- Last Synced: 2025-08-04T00:58:23.691Z (6 months ago)
- Topics: basic-authentication, http, koa, middleware, nodejs
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/koa-http-basic-auth
- Size: 32.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# koa-http-basic-auth [](https://travis-ci.org/baptistelambert/koa-http-basic-auth)
## Installation
npm
```
npm install --save koa-http-basic-auth
```
yarn
```
yarn add koa-http-basic-auth
```
## Usage
```js
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);
```