mongodb - Rails Mongoid fails to authenticate - failed with error 13: "not authorized for query on my_db.my_collection" -
this issue said resolved latest version of moped still happens me. have rails 4.2 app mongoid, created user mongodb db readwrite , dbowner roles, , set auth=true in mong.conf file.
can perform actions on db user credentials using mongo shell or simple java application using mongo driver.
however, when trying authenticate mongoid always error:
failed error 13: "not authorized query on my_db.my_collection"
here relevant portion of mongoid.yml file:
production: # configure available database sessions. (required) sessions: # defines default session. (required) default: # defines name of default database mongoid can connect to. # (required). database: my_db hosts: - localhost:27017 username: my_username password: my_password
i've tried replacing host remote address of server , access remotely ( works authentication option disabled ) without success. what's worth, can see credentials debugging mpped/node.rb file, in ensure_connected method see @credentials variable contains username , password missing here? thanks!
ran problem also. willing guess running mongodb 3+?
the bad news: moped 2 (which used mongoid today) not support authentication mongodb 3+.
moped falls short on lot of essential functionality supporting server version 3.0. example, doesn’t support authentication mongodb 3.0 or recent versions of wire protocol (which includes commands such listcollections, listindexes, , ability bulk writes). integrating mongoid ruby driver 2.0 bring lot of functionality , forward-compatibility odm. source
the news: major rewrite underway right (mongoid 5), supported mongodb team. can pull master today , test out...but not recommend production yet highly unstable.
solution options
- remove user/pass auth mongodb , public dns database. use ssh private key , connect private address.
- downgrade mongodb 2.x
- use mongoid 5
Comments
Post a Comment