cobrateam / flask-mongoalchemy

Flask support for MongoDB using MongoAlchemy.
https://pythonhosted.org/Flask-MongoAlchemy/
BSD 2-Clause "Simplified" License
217 stars 45 forks source link

MongoDB URI should include the database #21

Closed fsouza closed 13 years ago

fsouza commented 13 years ago

For authentication reasons, the MongoDB URI should include the database.

Details, extracted from Flask mailing list:

On Tue, Aug 23, 2011 at 8:41 AM, Ishbir Singh <...> wrote:
Hey,

This throws the same error, but when I try host='mongodb://user:password@188.88.88.2:27017/database', then it works.. I created a user for the database, not for the entire server, because, that would be insecure otherwise.

On 23 August 2011 02:51, Francisco Souza <...> wrote:
Can you execute this code below in the Python interactive console?

>>> import pymongo
>>> conn = pymongo.connection.Connection(host='mongodb://user:password@188.88.88.2:27017') # place your data here
>>> conn.database

Cheers,
Chico (a.k.a Francisco Souza)
@franciscosouza

On Mon, Aug 22, 2011 at 11:21 AM, Ishbir Singh <...> wrote:
Hey, here you go-

Traceback (most recent call last):
  File "manage.py", line 3, in <module>
    from lulzimg import app
  File "/var/script/script/__init__.py", line 25, in <module>
    db.init_app(app)
  File "/usr/local/lib/python2.7/dist-packages/flaskext/mongoalchemy.py", line 108, in init_app
    host=uri,
  File "/usr/local/lib/python2.7/dist-packages/mongoalchemy/session.py", line 83, in connect
    conn = Connection(*args, **kwds)
  File "/usr/local/lib/python2.7/dist-packages/pymongo/connection.py", line 333, in __init__
    raise ConfigurationError("authentication failed")
pymongo.errors.ConfigurationError: authentication failed

On 22 August 2011 18:42, Francisco Souza <...> wrote:
Hey there,

On Mon, Aug 22, 2011 at 8:57 AM, Ishbir Singh <...> wrote:

Hey there,

I realize that this might not be related to Flask in anyway, but I still wanted to get some help. What I have are 2 servers, one running MongoDB server and the other is the client. Now, I'm trying to access the server from the client by using appropriate credentials and port numbers. The connection is successful via the command-line mongo tool but while using the exact same settings with Flask-MongoAlchemy, it says that authentication failed.

Could you please paste the stack trace here? 

Cheers,
Chico (a.k.a Francisco Souza)
@franciscosouza

On Mon, Aug 22, 2011 at 8:57 AM, Ishbir Singh <...> wrote:
Hey there,

I realize that this might not be related to Flask in anyway, but I still wanted to get some help. What I have are 2 servers, one running MongoDB server and the other is the client. Now, I'm trying to access the server from the client by using appropriate credentials and port numbers. The connection is successful via the command-line mongo tool but while using the exact same settings with Flask-MongoAlchemy, it says that authentication failed.

I know that the settings are valid, I know that the firewall is not blocking requests. What could be the fault?

config.py in the client server-

MONGOALCHEMY_DATABASE = 'database'
MONGOALCHEMY_SERVER = '188.88.88.2'
MONGOALCHEMY_USER = 'user'
MONGOALCHEMY_PASSWORD = 'password'

I'm using Flask-MongoAlchemy by the way.

-- 
Regards,
Ishbir Singh

-- 
Regards,
Ishbir Singh

-- 
Regards,
Ishbir Singh