Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

apache-crypt dependency is truly optional.

  • Loading branch information...
commit fc0265f051367d5f4c7a92de561216ae178b0a3e 1 parent ed5e5e7
Gevorg Harutyunyan authored
2  lib/auth/basic.coffee
@@ -34,7 +34,7 @@ class Basic extends Base
34 34 ]
35 35 else # File based.
36 36 for user in @options.users # Loop users to find the matching one.
37   - if user.username is username and htpasswd user.hash, password
  37 + if user.username is username and htpasswd.verify user.hash, password
38 38 found = true
39 39 break # Stop searching, we found him.
40 40
4 package.json
... ... @@ -1,7 +1,7 @@
1 1 {
2 2 "name": "http-auth",
3 3 "description": "Node.js package for HTTP basic and digest access authentication.",
4   - "version": "2.1.5",
  4 + "version": "2.1.6",
5 5 "author": "Gevorg Harutyunyan (http://github.com/gevorg)",
6 6 "maintainers": [
7 7 {
@@ -27,7 +27,7 @@
27 27 "dependencies": {
28 28 "coffee-script": "1.6.3",
29 29 "node-uuid": "1.4.1",
30   - "htpasswd": "2.0.9"
  30 + "htpasswd": "2.1.0"
31 31 },
32 32 "devDependencies": {
33 33 "nodeunit": "0.8.1",
16 tests/test-basic.coffee
@@ -7,6 +7,9 @@ http = require 'http'
7 7 # Authentication library.
8 8 auth = require '../lib/http-auth'
9 9
  10 +# htpasswd verification is reused.
  11 +htpasswd = require 'htpasswd'
  12 +
10 13 module.exports =
11 14
12 15 # Before each test.
@@ -39,12 +42,15 @@ module.exports =
39 42
40 43 # Correct Crypt details.
41 44 testSuccessCrypt: (test) ->
42   - callback = (error, response, body) -> # Callback.
43   - test.equals body, "Welcome to private area - vera!"
44   - test.done()
  45 + if htpasswd.isCryptInstalled()
  46 + callback = (error, response, body) -> # Callback.
  47 + test.equals body, "Welcome to private area - vera!"
  48 + test.done()
45 49
46   - # Test request.
47   - (request.get 'http://127.0.0.1:1337', callback).auth 'vera', 'kruta'
  50 + # Test request.
  51 + (request.get 'http://127.0.0.1:1337', callback).auth 'vera', 'kruta'
  52 + else
  53 + test.done()
48 54
49 55 # Correct MD5 details.
50 56 testSuccessMD5: (test) ->

0 comments on commit fc0265f

Please sign in to comment.
Something went wrong with that request. Please try again.