eb

express-basicauth

A simple express middleware for basic authentication

Showing:

Popularity

Downloads/wk

28

GitHub Stars

0

Maintenance

Last Commit

4yrs ago

Contributors

1

Package

Dependencies

2

Size (min+gzip)

3.4KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

express-basicauth

Build Status

A simple express middleware for basic authentication

How to install

Install with npm:

npm install --save express-basicauth

How to use with Express

This will authenticate if username entered is 'username' and password entered is 'password'.

var express = require('express');
var basicAuth = require('express-basicauth');
var app = express();


app.use(basicAuth());

Using a custom username and password:

var express = require('express');
var basicAuth = require('express-basicauth');
var app = express();


app.use(basicAuth({username: 'name', password: 'pass' }));

You can also optionally provide your own custom athenticator.

var express = require('express');
var basicAuth = require('express-basicauth');
var app = express();

/**
 * All you need is a function which returns a promise that is resolved once authenticated.
 * You can also use async functions for this 
 */
function myCustomAuthenticator(username, password) {
    let authenticated = false;

    // add authentication logic 

    return authenticated ? Promise.resolve() : Promise.reject();
}

app.use(basicAuth({authenticator: myCustomAuthenticator}));

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100