Skip to content

Simple basic auth middleware to be used with Express.js

Notifications You must be signed in to change notification settings

GabrielCastello/basic-auth

Repository files navigation

Basic-Auth to be used with Express.js

Build Status Coverage Status Dependencies

https://nodei.co/npm/@g4br13l/basic-auth.png?downloads=true&downloadRank=true&stars=true

How to install

  npm i @g4br13l/basic-auth

How to use

const router = express.Router();

const BasicAuth = require("@g4br13l/basic-auth");
const newBasicAuth = new BasicAuth("testUser", "testPassword");

router.get("/test", newBasicAuth.protect, (req, res, next) => res.status(200).send());

module.exports = router;

Responses

Matching Credentials

StatusCode: 200

Sends next() to express

Invalid credentials

StatusCode: 401

{
  "message": "Invalid Authentication Credentials"
}

No authentication provided

StatusCode: 401

{
  "message": "Missing Authorization Header"
}

About

Simple basic auth middleware to be used with Express.js

Resources

Stars

Watchers

Forks

Packages

No packages published