Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing a user's password doesn't work #438

Closed
webcompas opened this issue Feb 5, 2018 · 1 comment
Closed

Changing a user's password doesn't work #438

webcompas opened this issue Feb 5, 2018 · 1 comment

Comments

@webcompas
Copy link
Contributor

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 4.10.9
  • Ruby: 2.3.1p112
  • Distribution: Ubuntu 16.04
  • Module version: 2.0.0

How to reproduce (e.g Puppet code you use)

  1. Create a database user
mongodb_user { "foobar":
    username      => 'foo',
    database      => 'bar',
    password      => '12345',
    roles         => ['readWrite'],
  }
  1. Change Puppet code to use "abcde" as password
  2. Try to authenticate to MongoDB using the new password

What are you seeing

After Step 1 authentication succeeds. But after changing to another password it fails:

root@test:~# mongo -u foo -p abcde bar
MongoDB shell version: 2.6.10
connecting to: bar
2018-02-05T09:35:31.723+0100 Error: 18 { ok: 0.0, errmsg: "auth failed", code: 18 } at src/mongo/shell/db.js:1287
exception: login failed

Trying to authenticate using the previous password works:

root@test:~# mongo -u foo -p abcde bar
MongoDB shell version: 2.6.10
connecting to: bar
>

What behaviour did you expect instead

Authentication using the new password should work.

Any additional information

When running Puppet Agent at step 2 there are no error messages. According to the debug output the password change is done using the following command:
Debug: Executing '/usr/bin/mongo bar --quiet --host 127.0.0.1:27017 --eval load('/root/.mongorc.js'); db.runCommand({"updateuser": "foo","pwd": "abcde","digestpassword": true})'

If I run the command manually I get the error "no such cmd: updateuser":

root@test-pu-mongodb:~# mongo bar
MongoDB shell version: 2.6.10
connecting to: bar
> db.runCommand({"updateuser": "foo","pwd": "abcde","digestpassword": true});
{
        "ok" : 0,
        "errmsg" : "no such cmd: updateuser",
        "code" : 59,
        "bad cmd" : {
                "updateuser" : "foo",
                "pwd" : "bar",
                "digestpassword" : true
        }
}

Comparing the password hash within MongoDB with the expected one shows that it is still using the one for the old password.

@webcompas
Copy link
Contributor Author

The reason for the error is the wrong spelling of the Mongo command. Instead of updateuser it has to be updateUser.
Additionally Mongo shell 2.6 doesn't support param "digestpassword" (see https://docs.mongodb.com/v2.6/reference/method/db.updateUser/).

webcompas added a commit to webcompas/puppet-mongodb that referenced this issue Feb 5, 2018
webcompas added a commit to webcompas/puppet-mongodb that referenced this issue Feb 5, 2018
bastelfreak added a commit that referenced this issue Feb 13, 2018
Fix password changing issue #438
webcompas pushed a commit to webcompas/puppet-mongodb that referenced this issue Feb 14, 2018
webcompas added a commit to webcompas/puppet-mongodb that referenced this issue Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant