Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for MongoDB authentication (digest). #202

Closed
HowToMeetLadies opened this issue Mar 27, 2013 · 5 comments
Closed

Add support for MongoDB authentication (digest). #202

HowToMeetLadies opened this issue Mar 27, 2013 · 5 comments

Comments

@HowToMeetLadies
Copy link
Contributor

Hello, I've implemented an authentication adapter for MongoDB, please have a look at: HowToMeetLadies/vibe.d@2438a64e58.

I'll send a pull request if it fits, have also done a driver for GridFS (w/ versioning) and an simple admin-helper (databases, user managment, stats)..

Cheers
Christian

@HowToMeetLadies
Copy link
Contributor Author

That was too fast, had to commit again.

HowToMeetLadies/vibe.d@6ab7975849

@s-ludwig
Copy link
Member

s-ludwig commented Apr 5, 2013

Both would be very good additions. In case of the authentication code I would like to integrate it as MongoDatabase.authenticate(), mainly for two reasons:

  • Because of the ConnectionPool it could be that some queries get a different connection than others and thus would have to authenticate again. As a way around that, MongoClient could store a map from database name to credentials and automatically reissue them for new connections (+ reissue them after a reconnect in MongoConnection, an additional callback is needed there)
  • Credentials could be specified in the URL passed to connectMongoDB and those could then directly be put into the credentials map.

If you want to tackle that and make a pull request that would be great. Otherwise I could also take your code and integrate it when I have some time (with permission and credit of course).

Btw. wouldn't the admin helper make a nice little stand-alone project? A colleauge just searched for something like that and went with MongoVue, I think. A simple browser based alternative would actually have been sufficient/preferred in that case, but all of them required installing a scripting host/web server. So a vibe.d based one would have been perfect in that case.

Also, sorry for the late reply I was away last week and forced myself to work exclusively on another project to make some more serious progress there finally.

@HowToMeetLadies
Copy link
Contributor Author

@s-ludwig Hello and sorry for the delay, had some trouble last days.. Of course you can take it if you want, but see my current changeset. Btw, are you available on IRC or something?

In the newest version of MongoDB they introduced roles and a new format for privileges, now you need to login only once.

I've rewritten my code so it is now integrated into MongoConnection and authenticates on every connect with credentials specified via URL. Also, rewritten connectMongoDB to accept an IMongoAuthenticator.

To get authentication running you have to call it like:

import vibe.db.mongo.auth;
auto mongo = connectMongoDB("mongodb://admin:[email protected]", new MongoAuthCR);

MongoAdmin An alternative to MongoVue would be indeed nice but I do not have the time for another project, at least at the moment..

@s-ludwig
Copy link
Member

Hello, no problem at all with the delay! I think the current version generally looks good, so no need for me to reorganize it. I'm not on IRC anywhere, though (In my past tries I never really liked it and thus never really started using it).

Just one thing regarding IMongoAuthenticator: Is there anything on the horizon for which this might be neededin the future? If in practice there will only be the need for the simple digest authentication like it is currently implemented, I would just put the code from MongoAuthCR directly into MongoConnection to not needlesly blow up the public API (if some unexpected use comes up for an abstraction there, it can always be added without breaking backwards compatibility).

@s-ludwig
Copy link
Member

Implemented by #218.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants