0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-23 22:27:34 -05:00
verdaccio/packages/plugins/htpasswd
renovate[bot] 0aa7cf5c63
chore(deps): update dependency @testing-library/dom to v9.3.4 (master) (#4401)
* chore(deps): update dependency @testing-library/dom to v9.3.4

* Update htpasswd.test.ts

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Juan Picado <juanpicado19@gmail.com>
2024-01-14 12:56:15 +01:00
..
src update major dependencies, remove old nodejs support (#4059) 2023-10-07 16:23:04 +02:00
tests chore(deps): update dependency @testing-library/dom to v9.3.4 (master) (#4401) 2024-01-14 12:56:15 +01:00
.babelrc chore: refactor pkgs location (#2538) 2021-10-18 22:18:09 +02:00
.eslintignore chore: refactor pkgs location (#2538) 2021-10-18 22:18:09 +02:00
.eslintrc.json chore: refactor pkgs location (#2538) 2021-10-18 22:18:09 +02:00
CHANGELOG.md chore: update versions (next-7) (#4417) 2024-01-14 10:56:23 +01:00
htpasswd chore: refactor pkgs location (#2538) 2021-10-18 22:18:09 +02:00
jest.config.js chore: refactor pkgs location (#2538) 2021-10-18 22:18:09 +02:00
LICENSE chore: refactor pkgs location (#2538) 2021-10-18 22:18:09 +02:00
package.json chore: update versions (next-7) (#4417) 2024-01-14 10:56:23 +01:00
README.md fix: refactor htpasswd plugin to use the bcryptjs 'compare' api call instead of 'compareSync' (#3025) 2022-03-03 21:57:19 +01:00
tsconfig.build.json chore: refactor pkgs location (#2538) 2021-10-18 22:18:09 +02:00
tsconfig.json refactor logger module (#3592) 2023-02-05 21:00:32 +01:00

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.

This plugin is being used as dependency after v3.0.0-beta.x. The v2.x still contains this plugin built-in.

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".
        #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.

Plugin Development in Verdaccio

There are many ways to extend Verdaccio, currently it support authentication plugins, middleware plugins (since v2.7.0) and storage plugins since (v3.x).

License

FOSSA Status