I need a mongo client with user of only read access for all databases. Also i need the ruby mongo client to be created without the password hardcoded?
Any suggestions.
just use standard ruby mongo driver: https://github.com/mongodb/mongo-ruby-driver
here you have API documentation in which you'll find details on authentication (essentially it requires passing user
and password
keys in initialization data): http://api.mongodb.com/ruby/2.5.0/Mongo/Client.html
--
Also i need the ruby mongo client to be created without the password hardcoded
You can always keep authentication details in your app's config
OR
for example pass it in environment variables when starting process [they will be available through ENV
hash]. Example of how it is used RAILS_ENV=developent rails s
- RAILS_ENV
is an environment variable accessible in your app by ENV['RAILS_ENV']
If you decide to do it this way you can keep authentication outside your app on the machine on which you're running your app.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.