Socket
Socket
Sign inDemoInstall

passport-local-htpasswd

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

passport-local-htpasswd

Local username and password authentication strategy for Passport.


Version published
Weekly downloads
14
decreased by-46.15%
Maintainers
1
Weekly downloads
 
Created
Source

passport-local-htpasswd

A passport strategy for using bcrypted htpasswd files. This behaves virtually identically to passport-local, except that simply specifying a htpasswd is enough to provide basic authentication. As these files contain no user information, you are on your own with that.

This isn't intended as a full production model for authentication. However, it doesn't require a database and provides a basic and reasonably secure authentication system with the simplicity of maintenance from the htpasswd command.

Significant portions of this module were derived from passport-local by Jared Hanson.

Usage

The module works with htpasswd files created using bcrypt only. For example, to create a password file, use a command like this:

htpasswd -c -B .htpasswd myuser
Configure Strategy

The local authentication strategy authenticates users using a username and password. The strategy requires a verify callback, which accepts these credentials and calls done providing a user.

passport.use(new LocalHtpasswdStrategy({file: filename});
Authenticate Requests

Use passport.authenticate(), specifying the 'local-htpasswd' strategy, to authenticate requests.

For example, as route middleware in an Express application:

app.post('/login', 
  passport.authenticate('local-htpasswd', { failureRedirect: '/login' }),
  function(req, res) {
    res.redirect('/');
  });
Data

The module doesn't store or persist users. The user is made available as an object with a single property username with the given username.

Keywords

FAQs

Package last updated on 06 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc