# basic-auth-connect

> Basic auth middleware for node and connect

Latest version **1.1.0** (published 2024-09-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install basic-auth-connect
pnpm add basic-auth-connect
yarn add basic-auth-connect
bun add basic-auth-connect
```

## Health

**Score 35/100 (D)** — status: stable.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2024-09-30 |
| First published | 2014-01-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 134 |
| Author | Jonathan Ong |
| Maintainers | ulisesgascon, dougwilson, fishrock123, tjholowaychuk, jongleberry, defunctzombie |

## Links

- npm: https://www.npmjs.com/package/basic-auth-connect
- Repository: https://github.com/expressjs/basic-auth-connect
- Homepage: https://github.com/expressjs/basic-auth-connect#readme
- Issues: https://github.com/expressjs/basic-auth-connect/issues
- npm.io page: https://npm.io/package/basic-auth-connect

## Dependencies (1)

- [tsscmp](https://npm.io/package/tsscmp.md) ^1.0.6

## Recent versions

- 1.1.0 (latest) — 2024-09-30
- 1.0.0 — 2014-01-08

## README

# basic-auth-connect

Connect's Basic Auth middleware in its own module. You should consider to create your own middleware with [basic-auth](https://github.com/visionmedia/node-basic-auth).

## API

```js
var basicAuth = require('basic-auth-connect');
```

Simple username and password

```js
connect()
.use(basicAuth('username', 'password'));
```

Callback verification

```js
connect()
.use(basicAuth(function(user, pass){
  return 'tj' == user && 'wahoo' == pass;
}))
```

Async callback verification, accepting `fn(err, user)`.

```js
connect()
.use(basicAuth(function(user, pass, fn){
  User.authenticate({ user: user, pass: pass }, fn);
}))
```

**Security Considerations**

Important: When using the callback method, it is recommended to use a time-safe comparison function like [crypto.timingSafeEqual](https://nodejs.org/api/crypto.html#cryptotimingsafeequala-b) to prevent timing attacks.

## License

[MIT](./LICENSE)

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