puppet-mongodb icon indicating copy to clipboard operation
puppet-mongodb copied to clipboard

Fix password changing for SHA-1 mechanism #649

Open makhovaa opened this issue 3 years ago • 0 comments

Pull Request (PR) description

Added the mechanism parameter for the password_hash command

 def password_hash=(_value)
    if db_ismaster
      command = {
        updateUser: @resource[:username],
        pwd: @resource[:password_hash],
        digestPassword: false
      }
      command[:mechanisms] = @resource[:auth_mechanism] == :scram_sha_1 ? ['SCRAM-SHA-1'] : ['SCRAM-SHA-256']

      mongo_eval("db.runCommand(#{command.to_json})", @resource[:database])
    else
      Puppet.warning 'User password operations are available only from master host'
    end
  end

Changed unit test for mongodb_user due to new expected line generated for password_hash command.

This Pull Request (PR) fixes the following issues

Fixes #649

makhovaa avatar Oct 27 '22 15:10 makhovaa