Skip to content

Latest commit

 

History

History
47 lines (35 loc) · 1.32 KB

readme.md

File metadata and controls

47 lines (35 loc) · 1.32 KB

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"
}