Skip to content

Commit

Permalink
Htdgiest support.
Browse files Browse the repository at this point in the history
  • Loading branch information
gevorg committed Dec 4, 2011
1 parent 3715a69 commit f01a484
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/auth/digest.js
Expand Up @@ -82,7 +82,7 @@ Digest.prototype.isAuthenticated = function(request) {

// Username is correct.
if(userHash && typeof userHash === 'string') {
var ha1 = this.users[co.username];
var ha1 = this.users[co.username].split(":")[2];

// If algorithm is MD5-sess.
if(co.algorithm == 'MD5-sess') {
Expand Down
5 changes: 2 additions & 3 deletions lib/options.js
Expand Up @@ -58,9 +58,8 @@ module.exports = function(options) {
var authLine = authList[i];

if(authType == 'digest') {
var authTokens = authLine.split(":");
// Constructing A1 for digest access authentication.
authUsers[authTokens[0]] = authTokens[0] + ":" + authRealm + ":" + authTokens[1];
var authTokens = authLine.split(":");
authUsers[authTokens[0]] = authLine;
} else if(authType == 'basic') {
authUsers.push(authLine);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/auth/test-digest.js
Expand Up @@ -28,7 +28,8 @@ defaults.NONCE_EXPIRE_TIMEOUT = 0;
*/
exports['setUp'] = function(callback) {
// Initiates basic instance before each test.
source = new Digest("AweSome REALM", {"mia" : "mia:Private area.:supergirl"}, 'MD5');
source = new Digest("AweSome REALM", {"mia" :
"mia:Private area.:3a556dc7260e8e7f032d247fb668b06b"}, 'MD5');
// GOD knows why I need to call this.
callback();
};
Expand Down
9 changes: 6 additions & 3 deletions tests/test-options.js
Expand Up @@ -116,14 +116,17 @@ exports['testValidAuthListDigest'] = function (test) {
// Checking for valid authList.
var options = opt({
authRealm : "Some realm",
authList : ['karo:seed', 'samvel:beed'],
authList : ['samvel:Some realm:a14d1baeb46dd3f44d177cd28331f921',
'karo:Some realm:24b0b93d4e91583f77ee6da31ebeebc8'],
authType : 'digest'
});
// Checking not empty.
test.notEqual(options.authUsers, null, "authUsers must not be empty!");
// Checking for items.
test.equals(options.authUsers['karo'], 'karo:Some realm:seed', "User item is wrong!");
test.equals(options.authUsers['samvel'], 'samvel:Some realm:beed', "User item is wrong!");
test.equals(options.authUsers['karo'], 'karo:Some realm:24b0b93d4e91583f77ee6da31ebeebc8',
"User item is wrong!");
test.equals(options.authUsers['samvel'], 'samvel:Some realm:a14d1baeb46dd3f44d177cd28331f921',
"User item is wrong!");
// Test is done.
test.done();
};
Expand Down

0 comments on commit f01a484

Please sign in to comment.