Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Commit

Permalink
CouchDB now uses PBKDF2 instead of salted hashes
Browse files Browse the repository at this point in the history
However, only if you pass in an un-encrypted password.

This is thus the first step in verifying that doing this won't result
in having unencrypted passwords anywhere along the chain.
  • Loading branch information
isaacs committed Feb 23, 2014
1 parent 33c19d5 commit effb4bc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
5 changes: 2 additions & 3 deletions lib/adduser.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ function adduser (username, password, email, cb) {
var salt = crypto.randomBytes(30).toString('hex')
, userobj =
{ name : username
, salt : salt
, password_sha : sha(password + salt)
, password : password
, email : email
, _id : 'org.couchdb.user:'+username
, type : "user"
Expand All @@ -51,7 +50,7 @@ function adduser (username, password, email, cb) {
cb = done.call(this, cb, pre)

var logObj = Object.keys(userobj).map(function (k) {
if (k === 'salt' || k === 'password_sha') return [k, 'XXXXX']
if (k === 'password') return [k, 'XXXXX']
return [k, userobj[k]]
}).reduce(function (s, kv) {
s[kv[0]] = kv[1]
Expand Down
4 changes: 1 addition & 3 deletions test/adduser-new.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ tap.test("create new user account", function (t) {

req.on("end", function () {
var o = JSON.parse(b)
var salt = o.salt
userdata.salt = salt
userdata.password_sha = sha(password + salt)
userdata.password = password
userdata.date = o.date
t.deepEqual(o, userdata)

Expand Down
4 changes: 1 addition & 3 deletions test/adduser-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ tap.test("update a user acct", function (t) {

req.on("end", function () {
var o = JSON.parse(b)
var salt = o.salt
userdata.salt = salt
userdata.password_sha = sha(password + salt)
userdata.password = password
userdata.date = o.date
t.deepEqual(o, userdata)

Expand Down

0 comments on commit effb4bc

Please sign in to comment.