Created
May 23, 2014 19:27
-
-
Save jbrechtel/603475bc8b03e020203c to your computer and use it in GitHub Desktop.
auth?!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#mongo 2.4 running with --auth | |
require 'mongo' | |
require 'json' | |
client = Mongo::MongoClient.new('localhost', 27017) | |
admin = { user: 'admin', pwd: 'password', roles: ['readWriteAnyDatabase', 'userAdminAnyDatabase', 'clusterAdmin'] } | |
user = { user: 'app', pwd: 'password', roles: ['readWrite'] } | |
client['admin'].eval("db.addUser(#{admin.to_json})") | |
client['admin'].authenticate('admin', 'password') | |
client['appDb'].eval("db.addUser(#{user.to_json})") #Database command '$eval' failed: unauthorized (Mongo::OperationFailure) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment