Wednesday, 7 August 2013

Using authentification with DoctrineMongoDBBundle

Using authentification with DoctrineMongoDBBundle

I need your help, pls.
I'm currently working on a project where I use mongodb as database, and I
began with no security in my mongo configuration of the symfony
config.yml.
This is what my config.yml looked like since the beginning of the project.
doctrine_mongodb:
connections:
default:
server: mongodb://localhost:27017
options: {}
default_database: louisv
document_managers:
default:
auto_mapping: true
With this parameters the project works very well.
But I want to add security to mongodb database. So I tried to follow
documentation on mongodb to create users. I created an "admin" user for
the admin database, and a "louisv" user for the louisv database (the admin
database is the database existing by default, and louisv is mine).
Now I want to Symfony to use this new user. I changed my the option
parameters from my conf.yml file and now this is what I have :
doctrine_mongodb:
connections:
default:
server: mongodb://localhost:27017
options:
username: louisv
password: password
default_database: louisv
document_managers:
default:
auto_mapping: true
Now when I try to enter my application in Symfony
Failed to connect to: localhost:27017: Authentication failed on database
'admin' with username 'louisv': auth fails
Which is weird cause my default_database is "louisv' and not 'admin'.
And if I change the credentials to admin's ones, I have another error :
localhost:27017: not authorized for query on louisv.User
Which seems quite good as it seems to search for users, but I can't do
queries.
I really stuck at this point for days, so you're my last hope, thanking
you in anticipation !

No comments:

Post a Comment