expressjs/basic-auth-connect

Basic auth middleware for node and connect

JavaScript

134

18 commits

updated Mar 1, 2026

See the code

README

basic-auth-connect

Connect's Basic Auth middleware in its own module. You should consider to create your own middleware with basic-auth.

API

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

Simple username and password

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

Callback verification

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

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

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 to prevent timing attacks.

License

MIT

expressjs/basic-auth-connect

Basic auth middleware for node and connect

JavaScript

134

18 commits

updated Mar 1, 2026

See the code

README

basic-auth-connect

Connect's Basic Auth middleware in its own module. You should consider to create your own middleware with basic-auth.

API

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

Simple username and password

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

Callback verification

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

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

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 to prevent timing attacks.

License

MIT

Project health

Overall

6.9/10

Maintained

0/10

Code review

7/10

Contributors

10/10
OpenSSF Scorecard

Latest release

1.1.0 · Sep 30, 2024

Releases this year

0