igorkasyanchuk / rails_db

Rails Database Viewer and SQL Query Runner
https://www.railsjazz.com/
MIT License
1.46k stars 111 forks source link

Requiring authentication to access Rails DB #1

Closed guisehn closed 8 years ago

guisehn commented 8 years ago

Currently is there any way to require authentication or some kind of permission checking before allowing users to access the Rails DB pages?

igorkasyanchuk commented 8 years ago

Yes,I can implement it, if you can check my other gem any_login itit's easy to make same here. Do you want to make it?

guisehn commented 8 years ago

@igorkasyanchuk I will take a look on it and see if I can make it. Thanks!

igorkasyanchuk commented 8 years ago

@guisehn you can do it :) Please take a look here https://github.com/igorkasyanchuk/any_login/tree/master/lib/generators/any_login (you need to create generator)

You need to do something like this https://github.com/igorkasyanchuk/any_login/blob/master/lib/any_login.rb#L12 and this https://github.com/igorkasyanchuk/any_login/blob/master/lib/any_login.rb#L59 (and below few lines)

Also you need do add this method https://github.com/igorkasyanchuk/any_login/blob/master/lib/any_login.rb#L71

And finally update documentation as here https://www.dropbox.com/s/jj4fijululbkpew/Screenshot%202015-10-16%2022.55.51.png?dl=0

:) if you have any questions please ask

guisehn commented 8 years ago

@igorkasyanchuk I added the possibility to implement the authorization code in a initializer file. I created the pull request https://github.com/igorkasyanchuk/rails_db/pull/2

Please give feedback, this is my first contribution to an existing open source project. :)

igorkasyanchuk commented 8 years ago

Look good, but only few things I'd like you to change. Since I plan (and maybe you also will have an ideas) to create more functionality around this gem, and I think we need to have generator for initializer similar to this what I've in any_login gem.

I want to make it super easy and clear to all people how to use it, because Proc's are not something what beginners understand and can use. So here something more simpler like "username", "password", "http_basic_auth_enabled" would be enough.

It'll be a start for future options which use can set in initializer. So if you don't mind please make it more flexible and easy to use :)

igorkasyanchuk commented 8 years ago

One more :) I know it from own experience, it's much easier to run a command to generate initializer then create file by your own. So it's really will simplify life. And please wrap it with "setup" block as it's good practice

guisehn commented 8 years ago

@igorkasyanchuk thanks for the feedback. I will try to implement those things when I get some free time.

igorkasyanchuk commented 8 years ago

Added

http_basic_authentication_enabled - Enable HTTP_BASIC authentication. http_basic_authentication_user_name - HTTP_BASIC authentication user name. http_basic_authentication_password - HTTP_BASIC authentication password.