Total Pageviews

Tuesday, 4 December 2018

htpasswd

Node.js package for HTTP Basic Authentication password file utility. 

CLI tool for managing HTTP Basic Authentication password file.
Basically, this is a Node.js implementation of Apache's htpasswd utility.
Build Status

Installation

Via git (or downloaded tarball):
$ git clone git://github.com/http-auth/htpasswd.git
Via npm:
$ npm install -g htpasswd

Usage

$ htpasswd [-cimBpsDv] [ -C cost ] passwordfile username
$ htpasswd -b[cmBpsDv] [ -C cost ] passwordfile username password

$ htpasswd -n[imBps] [ -C cost ] username
$ htpasswd -nb[mBps] [ -C cost ] username password

Options

  • -b - Use the password from the command line rather than prompting for it. This option should be used with extreme care, since the password is clearly visible on the command line. For script use see the -i option.
  • -i - Read the password from stdin without verification (for script usage).
  • -c - Create a new file.
  • -n - Don't update file; display results on stdout.
  • -m - Use MD5 encryption for passwords. This is the default.
  • -B - Use bcrypt encryption for passwords. This is currently considered to be very secure.
  • -C - This flag is only allowed in combination with -B (bcrypt encryption). It sets the computing time used for the bcrypt algorithm (higher is more secure but slower, default: 5, valid: 4 to 31).
  • -d - Use crypt() encryption for passwords. This algorithm limits the password length to 8 characters. This algorithm is insecure by today's standards.
  • -s - Use SHA encryption for passwords. This algorithm is insecure by today's standards.
  • -p - Do not encrypt the password (plaintext).
  • -D - Delete the specified user.
  • -v - Verify password. Verify that the given password matches the password of the user stored in the specified htpasswd file.

Running tests

It uses mocha, so just run following command in package directory:
$ npm test

Issues

You can find list of issues using this link.

Requirements

  • Node.js - Event-driven I/O server-side JavaScript environment based on V8.
  • npm - Package manager. Installs, publishes and manages node programs.

Dependencies

  • commander - node.js command-line interfaces made easy.
  • prompt - a beautiful command-line prompt for node.js.
  • apache-md5 - Node.js module for Apache style password encryption using md5.
  • apache-crypt - Node.js module for Apache style password encryption using crypt(3).
  • bcrypt.js - Optimized bcrypt in plain JavaScript with zero dependencies.

Development dependencies

  • mocha - simple, flexible, fun javascript test framework for node.js & the browser.
  • chai - BDD / TDD assertion framework for node.js and the browser that can be paired with any testing framework.
from https://github.com/http-auth/htpasswd
-----

如何清除用户名和密码

因为浏览器会记住用户名和密码,然后替我们做“自动登录”,那么该怎么样才能“登出”呢?

考虑这样一个场景,网站设置了多套用户名和密码,下发了部分给客户,结果客户反应说用户名和密码不对,那么此时,因为我已经登录成功了,无法再看到输入框,自然也无法测试。这个时候我们需要就是“登出”,清空浏览器的 “HTTP Basic Auth 缓存”。

在 Chrome 中,我们只要在 URL 前面加上 user@ 即可强制浏览器刷新它的缓存,弹出对话框。

例如,网站为 http://www.a.com,访问输入了密码以后,再使用 http://user@www.a.com 访问,就会重新弹出弹框。

No comments:

Post a Comment