Socket
Socket
Sign inDemoInstall

verdaccio-htpasswd

Package Overview
Dependencies
Maintainers
3
Versions
119
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

verdaccio-htpasswd

htpasswd auth plugin for Verdaccio


Version published
Weekly downloads
169K
decreased by-10.91%
Maintainers
3
Weekly downloads
 
Install size
Created

Package description

What is verdaccio-htpasswd?

The verdaccio-htpasswd package is a plugin for Verdaccio, a lightweight private npm proxy registry. This plugin allows you to manage user authentication using htpasswd files, which is a simple way to store usernames and passwords for HTTP authentication.

What are verdaccio-htpasswd's main functionalities?

User Authentication

This feature allows you to authenticate users against an htpasswd file. The code sample demonstrates how to set up the htpasswd plugin and authenticate a user.

const Htpasswd = require('verdaccio-htpasswd');
const config = { file: './htpasswd', max_users: 1000 };
const htpasswd = new Htpasswd(config);

htpasswd.authenticate('username', 'password', (err, user) => {
  if (err) {
    console.error('Authentication failed:', err);
  } else {
    console.log('Authenticated user:', user);
  }
});

User Registration

This feature allows you to register new users by adding them to the htpasswd file. The code sample demonstrates how to add a new user.

const Htpasswd = require('verdaccio-htpasswd');
const config = { file: './htpasswd', max_users: 1000 };
const htpasswd = new Htpasswd(config);

htpasswd.adduser('newuser', 'newpassword', (err, user) => {
  if (err) {
    console.error('User registration failed:', err);
  } else {
    console.log('Registered user:', user);
  }
});

Password Management

This feature allows you to change the password of an existing user. The code sample demonstrates how to change a user's password.

const Htpasswd = require('verdaccio-htpasswd');
const config = { file: './htpasswd', max_users: 1000 };
const htpasswd = new Htpasswd(config);

htpasswd.changePassword('username', 'newpassword', (err) => {
  if (err) {
    console.error('Password change failed:', err);
  } else {
    console.log('Password changed successfully');
  }
});

Other packages similar to verdaccio-htpasswd

Readme

Source

verdaccio (latest) Known Vulnerabilities CircleCI codecov FOSSA Status backers discord MIT node

Verdaccio Module For User Auth Via Htpasswd

verdaccio-htpasswd is a default authentication plugin for the Verdaccio.

Plugin only valid for verdaccio v5.x

Install

As simple as running:

$ npm install -g verdaccio-htpasswd

Configure

auth:
    htpasswd:
        file: ./htpasswd
        # Maximum amount of users allowed to register, defaults to "+infinity".
        # You can set this to -1 to disable registration.
        #max_users: 1000
        # Hash algorithm, possible options are: "bcrypt", "md5", "sha1", "crypt".
        # Default algorithm is crypt.
        #algorithm: bcrypt
        # Rounds number for "bcrypt", will be ignored for other algorithms.
        # Setting this value higher will result in password verification taking longer.
        #rounds: 10
        # Log a warning if the password takes more then this duration in milliseconds to verify.
        #slow_verify_ms: 200

Bcrypt rounds

It is important to note that when using the default bcrypt algorithm and setting the rounds configuration value to a higher number then the default of 10, that verification of a user password can cause significantly increased CPU usage and additional latency in processing requests.

If your Verdaccio instance handles a large number of authenticated requests using username and password for authentication, the rounds configuration value may need to be decreased to prevent excessive CPU usage and request latency.

Also note that setting the rounds configuration value to a value that is too small increases the risk of successful brute force attack. Auth0 has a blog article that provides an overview of how bcrypt hashing works and some best practices.

Logging In

To log in using NPM, run:

    npm adduser --registry  https://your.registry.local

Generate htpasswd username/password combination

If you wish to handle access control using htpasswd file, you can generate username/password combination form here and add it to htpasswd file.

How does it work?

The htpasswd file contains rows corresponding to a pair of username and password separated with a colon character. The password is encrypted using the UNIX system's crypt method and may use MD5 or SHA1.

License

FOSSA Status

Keywords

FAQs

Package last updated on 21 Apr 2023

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc