# @nx/basic-auth-middleware

> A configurable Basic Authentication Middleware for Express

Latest version **1.1.3** (published 2020-01-27) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @nx/basic-auth-middleware
pnpm add @nx/basic-auth-middleware
yarn add @nx/basic-auth-middleware
bun add @nx/basic-auth-middleware
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2020-01-27 |
| First published | 2020-01-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Nexum AG |
| Maintainers | jan.fischer.bitworking, jeykom, nexumag |
| Keywords | express, basic, auth, authentication, middleware |

## Links

- npm: https://www.npmjs.com/package/@nx/basic-auth-middleware
- Repository: https://github.com/nexumAG/basic-auth-middleware
- Homepage: https://github.com/nexumAG/basic-auth-middleware#readme
- Issues: https://github.com/nexumAG/basic-auth-middleware/issues
- npm.io page: https://npm.io/package/@nx/basic-auth-middleware

## 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.3 (latest) — 2020-01-27
- 1.1.2 — 2020-01-27
- 1.1.1 — 2020-01-27
- 1.1.0 — 2020-01-24

## README

# Basic Auth Middleware (express)
A middleware for express to configure a basic authentication.

Features:
- Basic Auth with Username, Password
- Whitelist for Hosts
- Whitelist for IP-addresses
- Whitelist for IP-ranges
- specified authentication for other hosts

## Installation
npm -i -S @nx/basic-auth-middleware

## Simple Example
```
const express = require('express');
const basicAuthMiddleware = require('@nx/basic-auth-middleware');
const app = express();

app.use(basicAuthMiddleware.default('test','test', {hostsWhitelist: ['localhost:3000']}));
app.get('/', (req, res) => {
  res.send('Huhu all (/)');
});

app.listen(3000, () => console.log('Listening to 3000'));
```

## Configuration
|Option|Type|Description|Example|
|------|----|-----------|-------|
|ipAddressWhitelist|string[]|disable basic auth for this ips|['127.0.0.1', '192.168.0.2']
|ipRangeWhitelist|string[]|disable basic auth for all ip addresses in the range|['10.10.0.0/16', '192.168.1.1/24']
|hostsWhitelist|string[]|disable basic auth for this hosts|['localhost:3000', '127.0.0.1']
|specificHostAuth|{[key: string]: {username: string, password: string}}|change username and password for the specific hosts|{'google.de': { username: 'test', password: 'test' } }

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