Skip to content
Browse files

js bug fix

  • Loading branch information...
1 parent 94082ae commit 3994eef208cfb1d2fc8671d24a7116abfd83f9c4 Contra committed Oct 3, 2011
Showing with 19 additions and 17 deletions.
  1. +6 −4 CHANGELOG.md
  2. +10 −11 lib/main.coffee
  3. +3 −2 package.json
View
10 CHANGELOG.md
@@ -1,14 +1,16 @@
-0.0.3 / September 17, 2011
+0.0.4 / October 3, 2011
==================
+ * JS bug fix
+0.0.3 / September 17, 2011
+==================
* Dependency clean
-
+
0.0.2 / September 5, 2011
==================
-
* Change project ownership from Contra to Fractal
0.0.1 / September 5, 2011
==================
-
* Start of the project
+
View
21 lib/main.coffee
@@ -1,6 +1,4 @@
-## I looked over https://github.com/thedjinn/node-http-digest while making this and used a lot of code
-## Thanks djinn!
-
+require('coffee-script');
require 'protege'
http = require 'http'
config = require './config'
@@ -15,22 +13,22 @@ parseHeader = (header) ->
return false
unless header.startsWithIgnoreCase 'digest'
return false
-
- out = {}
+
+ out = {}
# Remove 'Digest ' from the string
header = header.downcase().replace 'digest ', ''
chunks = header.split ', '
-
+
for piece in chunks
val = piece.trim().split '='
if val.length < 2
return false
out[val[0]] = val[1].replaceAll '"', ''
return out
-
+
authenticate = (request, header, username, password) ->
authinfo = parseHeader header
-
+
# Check for inconsistencies
if !authinfo
return false
@@ -42,7 +40,7 @@ authenticate = (request, header, username, password) ->
return false
if authinfo.username isnt username
return false
-
+
userAuth = authinfo.username + ':' + config.realm + ':' + password
methodAuth = request.method + ':' + authinfo.uri
@@ -57,10 +55,10 @@ authenticate = (request, header, username, password) ->
digest = (request, response, username, password, callback) ->
authenticated = false
-
+
if request.headers.authorization?
header = request.headers.authorization
-
+
if authenticate request, header, username, password
callback request, response
else
@@ -75,3 +73,4 @@ exports.createServer = (username, password, callback) ->
@server = http.createServer (request, response) ->
digest request, response, username, password, callback
return @server
+
View
5 package.json
@@ -1,12 +1,12 @@
{
"name":"digest",
"description":"HTTP Digest authentication for NodeJS",
- "version":"0.0.3",
+ "version":"0.0.4",
"homepage":"http://github.com/wearefractal/node-digest",
"repository":"git://github.com/wearefractal/node-digest.git",
"author":"Fractal <contact@wearefractal.com> (http://wearefractal.com/)",
"main":"./lib/main.coffee",
-
+
"dependencies":{
"coffee-script":"*",
"protege":">= 0.0.7",
@@ -22,3 +22,4 @@
}
]
}
+

0 comments on commit 3994eef

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