Connect to Mongo DB on MongoLab without Authorization? - mongodb

My Question:
Is there any way to connect to Mongo DB (hosted on MongoLab) without username and password ?
My Case:
I have created a free MongoLab account (https://mongolab.com) and also create new database -> collection -> document in it.
When I connect to Mongo DB (on Mongo Lab) without username and password, I was able to connect, but when I try to retrieve any data it gives me "unauthorized db:testing lock type:-1 client:...." error.
So I have created a DB User in MongLab as well and provide username and password at the time of connection. After that I am able to connect and retrieve data from Mongo DB.

MongoLab's multi-tenant database plans are on shared servers. We cannot give you the choice to forgo authentication. Even if you were ok with others seeing you data, the other tenants on the server you share would still not want you to see their data.
We have dedicated server plans where you have your own server. On those we could turn off authentication for you. Email us at support#mongolab.com.
As for your benchmarks - auth will not slow things down. The drivers do not authentication on each request, just each connection. If you use the driver properly it should all work well.
-will (MongoLab)

Related

Mongo db is not connecting

I have drupal8 application where I use various dbs. When i try to connect with mongo db by giving username and password, connection is not happening. I could connect with mongo db by mentioning server address alone.
note: mongodb is configured with username and password in my server
I tried below methods.
$this->connect_string = 'mongodb://user:password#serveraddress'; (not connecting)
$this->connect_string = 'mongodb://serveraddress'; (connecting)
#$this->connect_string = 'mongodb://user:password#serveraddress:27017/?authSource=dbname';(not connecting)
Php v-7.4, Drupal 8
developed custom module to connect with mongo db, to display news feed (news feed related information stored in mongo db).
how to pass user name & password to connect with mongo db?
Could not find any error logs in mongodb server.

Mongodb and AWS EC2 security issue

I am trying to connect EC2 and mongodb .. But after the connection is made and database creation... I created a collection and saved some values but they are geting deleted after 48 hours and another database is visible stating all your data are backed up and you need to pay to get the data back else data will be leaked
Amazon EC2 ip adresses known by hackers. They are trying to join database servers which has no password protection. Their scripts tries all ip adresses and mongo db port. If has no protection then copy datas, delete datas and put the some message as pay money to us.
At this point, please search how to add authentication to mongo db server.

Mongodbd login with Mongoose to new database

I use mongoDB in Atlas cloud but now I want to movie to a local database. I installed MongoDB and created a admin user. Now I connect with mongoose to :
mongodb://login:pass#db.myserver.com:27017/admin
Works well. Now I create a new development database "develop".
I try to connect
mongodb://login:pass#db.myserver.com:27017/develop
This failed to login. OK, I understand that the admin database is the "/admin" one and that user is authenticated to this database but I thought that an admin can access all databases in a mongodb server?
In Atlas I just created the develop database and connected to it without any problem.
How I can well connect with mongoose to the new develop database? Do I need to create a second admin for this database?
Ok, I found out that I have to name the auth database in my connection string.
mongodb://login:pass#db.myserver.com:27017/develop?authSource=admin

Doctrine MongoDB ODM Authentication, possible?

Is there a way to use MongoDB authentication in Doctrine MongoDB ODM?
equivilant to db.auth(username,password) in shell
The most robust method is to specify your username and password in the connection URI (e.g. mongodb://username:password#localhost), as that will allow the driver to re-authenticate if a connection is dropped and it needs to reconnect. You can also use MongoDB::authenticate() if you need to authenticate against various DB's in a single connection, but you will have to manually re-authenticate if the connection is dropped. See the connection documentation for more examples.

what's the easiest way to password protect mongodb database for remote user?

I have a mongodb running in my server, for local connections to the db I don't need any password to protect it(that is within the same physical machine, meaning connect to the server thru the 127.0.0.1 ip address).
But I don't want other people in the network be able connect to my database without password, only the authorized user. So I want to do password protection for the remote user.
How to do it?
Right now monogdb does not support authentication mode based on the user location. So that means if you run mongod with --auth that will apply to everyone.
There are no (yet) advanced authentication schemas like IP, protocol source, etc. For now you can only define if the user has read only or write permissions on a database. So basically the only thing mongodb cares is if you typed the right password for the right user.
Personally in all production environment I would recommend to use the secure mode, because even if you allow only connection from a localhost any users who has access to the local server or any malicious script on the host can easily wipe all your data.
The MongoDB Security and Authentication page has information on configuring user authentication and firewall settings.
Note that when you enable password authentication for a database, the authentication requirement will apply to both local and remote users (so you will also need to connect with a password through the local IP).
MongoDb does not offer an easy way to protect the database. I assume this is the reason why there are tens of thousands of mongodb instances on the net that are unprotected for hackers