bobthecow / genghis

The single-file MongoDB admin app
http://genghisapp.com
MIT License
1.45k stars 166 forks source link

Passenger: genghis.rb issues with read-only and DB specific users #138

Open davidgubler opened 11 years ago

davidgubler commented 11 years ago

To avoid the PHP driver's {} vs. [] issues, I tried the ruby version today. However, I have encountered issues with user accounts which only have limited permissions.

"root" user with access to everything works fine.

User with role "readWrite" on a single DB (NOT admin DB): "Add server" works fine, user shows up green, but clicking on it results in an error message "undefined method `databases' for nil:NilClass" and the attached stack trace (from Apache log). undefinedmethod (Sorry, I cannot attach text files)

User with role "read" on admin DB: User shows up in red after "Add server".

The very same readWrite user did work fine in the PHP version of Genghis (I didn't have the other one back then).

$ gem list backports (3.3.3) bson (1.9.2) json (1.8.0) mongo (1.9.0) multi_json (1.7.9) mustache (0.99.4) rack (1.5.2) rack-protection (1.5.0) rack-test (0.6.2) sinatra (1.4.3) sinatra-contrib (1.4.1) sinatra-mustache (0.1.0) tilt (1.4.1) vegas (0.1.11)

$ dpkg -l | grep ruby ii libaugeas-ruby1.8 0.4.1-1.1 ii libfcgi-ruby1.8 0.8.8-1 ii libruby 1:1.9.3 ii libruby1.8 1.8.7.358-7 ii libruby1.9.1 1.9.3.194-8.1+deb7u1 ii libshadow-ruby1.8 2.1.4-2 ii rdoc 4.4 ii ruby-json 1.7.3-3 ii ruby-passenger 3.0.13debian-1 ii ruby-rack 1.4.1-2.1 ii ruby-shadow 2.1.4-2 ii ruby1.8 1.8.7.358-7 ii ruby1.8-dev 1.8.7.358-7 ii rubygems 1.8.24-1

$ dpkg -l | grep passenger ii libapache2-mod-passenger 3.0.13debian-1 ii ruby-passenger 3.0.13debian-1

I think I'm running Genghis 2.3.8 in Passenger in Apache, however, I do not fully understand the ruby stack. Installing Genghis via downloaded rb file or via "gem install genghisapp" makes no difference.

bobthecow commented 11 years ago

Does it work if you run genghisapp as a standalone app rather than through Passenger?

davidgubler commented 11 years ago

Yes, it appears to work fine when running standalone! Just like the PHP version, only without the {} vs. [] issues. I guess I can live with that (mod_proxy to the rescue)...

I just verified it (again), running Genghis through Passenger still gives me the errors described above.

davidgubler commented 11 years ago

I ended up with the same issues when using mod_proxy, which makes me think that this is an Apache issue.

This is what happens with mod_proxy: If I request https://myhost.com/servers/readonly%40localhost%2Fmydb in the browser, mod_proxy encodes the second '%' before forwarding the URL, and thus the request will go to [...]%252Fmydb, which, in the end, produces exactly the same error as with Passenger. That's with AllowEncodedSlashes NoDecode enabled. If I disable AllowEncodedSlashes, I get the usual 404s as with the PHP version. Using a root user that can authenticate against the admin DB does work, of course, because then the DB url does not contain a slash.

Thus, I assume that the URL handling in Passenger is broken similar to that of mod_proxy.

bobthecow commented 11 years ago

Hrm. I guess Apache's not so good at URLs :-/

As much as it pains me, I'm planning a change for v3.0 which moves away from a direct map like this for URLs, mostly because of Apache.