yocontra / smog

HTML5/Node/WebSocket MongoDB panel
MIT License
443 stars 42 forks source link

Problem with authentication system #16

Open syrm opened 12 years ago

syrm commented 12 years ago

Still not ok. mongodb://admin:adminpassword@localhost:27017/admin?auto_reconnect : OK mongodb://admin:adminpassword@localhost:27017/otherdatabase?auto_reconnect : auth fails mongodb://otherdatabase:otherdatabasepassword@localhost:27017/otherdatabase?auto_reconnect : need to login

yocontra commented 12 years ago

AFAIK this is an issue with mongo core - my pull req has been accepted but hasn't been pushed into master.

akumpf commented 12 years ago

+1 Smog looks fantastic, but auth seems pretty important for any dataset you actually care about.

I've been trying different ways to authenticate with the database, but no luck (besides directly accessing admin as shown above).

Also a quick suggestions in the meantime: hide the password info in the URL in logs (seeing the password in plaintext gives me the willies).

Could be simple as this

// assume url is something like this
var url = "http://test:1234@localhost:27017/test";

// remove the username and password from the URL and show as placeholders.
var safeurl = url.replace(/(\:\/\/)(.*?)(\@)/, "://user:****@");

console.log(safeurl);
// result is: "http://user:****@localhost:27017/test"

Keep us posted if you have any other thoughts or workarounds! :)

yocontra commented 12 years ago

@akumpf - That log is for debugging and shouldn't really be there - feel free to remove it and pull req

yocontra commented 12 years ago

Can you guys check if this issue occurs with https://github.com/kissjs/node-mongoskin ?

akumpf commented 12 years ago

I think this pull request should take care of the logging issue. (of course you could just kill it instead).

https://github.com/wearefractal/smog/pull/18

akumpf commented 12 years ago

Ok. I think I've tracked the login problems down to admin.coffee.

The problem occurs because the script goes forward trying to perform admin operations (like getting the server status and build info) when using a non-admin user.

Returning null for failed data (or some other placeholder?) seems like a simple solution for now. In other words, try to get the admin info as currently built, but don't throw an error upstream on fail.

Additionally curious is that logging in as admin and trying to open a database outside of admin seems to not work and throw an error as well. Looking into this, for a mongo db with authentication, you must authenticate against the "admin" db before you an access other databases and perform admin operations. Adding a couple lines takes care of that, too :)

It's working great for me (trying admin auth, as well as per-database auth), so I'll create a pull request shortly.

Cheers, Adam

ghost commented 11 years ago

This looks great but is virtually useless w/out authentication working.

fabriziomoscon commented 11 years ago

Any updates on this? I wish to connect to a remote DB hosted by MongoLAB/Nodejitsu, I can connect via shell but not with smog... does anybody have a workaround?

yocontra commented 11 years ago

Not doing any more work on this version - will be doing a full rewrite and this will be fixed in that. Will accept PRs to fix it in the meantime though

BrandonCopley commented 11 years ago

are there any mongo clients like active admin that we can use now?

yocontra commented 11 years ago

@BrandonCopley - There are a few PHP based ones but I've never used them