HW 1.6 - shell authentication fail

Hello!
I am sorry to open another “homework - authentication failed” topic but i read through the other after trying many times by myself and still can’t figure out what is wrong :confused:
Here is the screenshot of the operation i do ( summarized):

  • testsaslauthd works, so there is no problem with LDAP configuration itself
  • createUser and rs.initiate() succeed

This lead me to restrict the problem to the configuration file: given the above conditions the only reason for
the mongo shell not to find the user is that it cannot communicate correctly with the saslauthd service right?
Following the videos and the guide provided on the docs (configure sasl/openldap - mongo docs ) i end up with this configuration file ( the others are obviously different on ports etc…)

systemLog:
  destination: file
  path: "/home/vagrant/M310-HW-1.6/r0/mongodb.log"
storage:
  dbPath: "/home/vagrant/M310-HW-1.6/r0"
processManagement:
  fork: true
replication:
  replSetName: "rs0"
security:
  authorization: "enabled"
  keyFile: "/home/vagrant/mongodb-shared_key"
setParameter:
  saslauthdPath: /var/run/saslauthd/mux
  authenticationMechanisms: "PLAIN"
net:
  port: 31160
  bindIp: localhost,database.m310.mongodb.university

I keep looking at those three configuration settings ( authorization , saslauthdPath, authenticationMechanisms) and cannot find an error, a typo or even something different to try.
Any ideas? :confused:

@Layer_58838

Unfortunately, your screen shots came out somewhat unclear and blurry. Try posting these as text, not a screen shot and we’ll try to help.

Oh, really? I can see it clear, weird :thinking: (i blurred the mongo configuration file, i thought it was recommended).

Nevermind, these are the command listed:

vagrant@database:~$ sudo testsaslauthd -u adam -p password -f /var/run/saslauthd/mux 
0: OK "Success"
vagrant@database:~$ mongo --port 31160
connecting to 127.0.0.1:31160/test
MongoDB Enterprise > rs.initiate()
{
    "info2": "no configuration specified. Using a default configuration for the set",
    "me" : "database.m310.mongodb.university:31160",
    "ok": 1
}
MongoDB Enterprise rs0:OTHER> use admin
switched to db admin
MongoDB Enterprise rs0:PRIMARY> db.getSiblingDB("$external").createUser({user:"adam", roles: [{role:"root",db:"admin"}] })
Successfully added user: {
    "user" : "adam",
    "roles" : [
                {
                  "role" : "root",
                  "db" : "admin"
                 }
     ]
}
MongoDB Enterprise rs0:PRIMARY> db.getSiblingDB("$external").auth({mechanism:"PLAIN", user: "adam", pwd:"password", digestPassword: false})
Error: Authentication failed.
0

@Layer_58838

Well, I’ve copied all your steps that are shown here and this all works for me. Since the ‘testsaslauthd’ command worked, I know that the infrastructure system is up and running correctly, and I’m pretty sure I’ve got the configuration file matching yours. (Thank you BTW for being sensitive to posting code here – in this case, because the error isn’t obvious, I don’t have a problem with that, but I’m glad you’re thinking about it :smiley: )

I"d suggest going back to the beginning and killing all your mongod processes, clearing out the data directories, and starting again. Something clearly got lost in the process, but I can’t see what that is. Try that and post back here if you continue to have problems. Good luck.

1 Like