This package has been deprecated

Author message:

renamed to dummy-http-basic-auth

basic-auth-http
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

basic-auth-http

A simple object to implement http basic authentication.

Usage

import {Basic as auth} from 'basic-auth-http';

const app = express();
const auth = new Auth({
  file: '/path/to/user-password-pairs'
});

app.use((req, res, next) => {
  // returns 401 Unauthorized if check doesn't pass (the callback is not called, no next).
  auth.check(req, res, (err: Error) => {
    if (err) {
      next(err);
    }
    else {
      next();
    }
  });
});

You can check the test for more details

Installation

yarn add basic-auth-http

Notes

This is just a bit of code that I wrote for testing and for implementing in a private architecture. Use with caution. If you really want to secure your application you should also make use of https to encrypt the headers because http authorization is sending plain passwords in the request. If you wish to contribute you can propose a PR on the related github, I'd be glad to improve this tiny api.

Package Sidebar

Install

npm i basic-auth-http

Weekly Downloads

1

Version

0.1.3

License

MIT

Unpacked Size

14.6 kB

Total Files

20

Last publish

Collaborators

  • vdegenne