mongoengine get_db() does not raise an exception if password set to None
We use mongoengine==0.23.0 and utilize get_db() to check if mongoengine.connect() returns an authenticated pymongo.connection.Connection object. The behaviour is as expected if the password is incorrect, we get a Authentication failed., full error: {'ok': 0.0, 'errmsg': 'Authentication failed.', 'code': 18, 'codeName': 'AuthenticationFailed'} exception. However, if the password is set to None , get_db() does not raise an exception and the execution proceeds till the first mongoDB interaction is encountered, at which point we get the {'ok': 0.0, 'errmsg': 'there are no users authenticated', 'code': 13, 'codeName': 'Unauthorized'} exception. Is there a fix or a workaround for this ?
I find '+' in my password. And I remove it, then there is no error
I find '+' in my password. And I remove it, then there is no error
I means that you can reset your password by 0-9,a-z,A-Z, ".", "_"
I find '+' in my password. And I remove it, then there is no error
I means that you can reset your password by
0-9,a-z,A-Z, ".", "_"
Thank you chengwenxian ! Unfortunately, this is not the issue, the issue is that get_db works even when the password is none
I find '+' in my password. And I remove it, then there is no error
I means that you can reset your password by
0-9,a-z,A-Z, ".", "_"Thank you chengwenxian ! Unfortunately, this is not the issue, the issue is that get_db works even when the password is none
Is your authSource same with your db name? like this: mongodb://test:111111@localhost:27017/test_db?authSource=test_db
And create, grant user in your db. It resoved this problem, too.
@gilgamesh7 My guess is that this is a Pymongo behavior, not MongoEngine. I believe testing your connection right after connect is the recommended approach