diff --git a/lib/mongo/db.rb b/lib/mongo/db.rb index b53c337..a8551fd 100644 --- a/lib/mongo/db.rb +++ b/lib/mongo/db.rb @@ -161,7 +161,7 @@ module XGen auth['authenticate'] = 1 auth['user'] = username auth['nonce'] = nonce - auth['key'] = Digest::MD5.hexdigest("#{nonce}#{username}#{hash_password(password)}") + auth['key'] = Digest::MD5.hexdigest("#{nonce}#{username}#{hash_password(username, password)}") ok?(db_command(auth)) end @@ -461,8 +461,8 @@ module XGen private - def hash_password(plaintext) - Digest::MD5.hexdigest("mongo#{plaintext}") + def hash_password(username, plaintext) + Digest::MD5.hexdigest("#{username}:mongo:#{plaintext}") end end diff --git a/mongo-ruby-driver.gemspec b/mongo-ruby-driver.gemspec index 315259c..6bf3c67 100644 --- a/mongo-ruby-driver.gemspec +++ b/mongo-ruby-driver.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = 'mongo' - s.version = '0.4.2' + s.version = '0.4.3' s.platform = Gem::Platform::RUBY s.summary = 'Simple pure-Ruby driver for the 10gen Mongo DB' s.description = 'A pure-Ruby driver for the 10gen Mongo DB. For more information about Mongo, see http://www.mongodb.org.' diff --git a/tests/test_db.rb b/tests/test_db.rb index f8d5ff4..4f0ba80 100644 --- a/tests/test_db.rb +++ b/tests/test_db.rb @@ -24,7 +24,7 @@ class DBTest < Test::Unit::TestCase @spongebob_password = 'squarepants' @users = @db.collection('system.users') @users.clear - @users.insert(:user => @spongebob, :pwd => @db.send(:hash_password, @spongebob_password)) + @users.insert(:user => @spongebob, :pwd => @db.send(:hash_password, @spongebob, @spongebob_password)) end def teardown