Skip to content

Authentication for web admin #1163

Closed
Closed

Description

@HorizonNet

It would be helpful to add an authentication mechanism to the web admin. That would make remote administration more secure.

Activity

  1. coffeemug commented on Jul 12, 2013

    @coffeemug
    Contributor

    @HorizonNet -- thanks for bringing this up and sorry for the delay. For now we tell users to set up a reverse proxy in front of RethinkDB web UI for authentication (we'll post a document on how to do it soon). I agree this isn't an ideal solution since it requires users to configure another server like nginx.

    There are two reasons why we haven't baked authentication into RethinkDB itself yet:

    • The RethinkDB web server would have to take special care to be secure, which is often error prone and requires significant time and peer review
    • If we add basic authentication, the next step is to add ssl support, which is a road we don't really want to get on

    That being said, I'll talk to some folks here about it and see what we can do. There might be a creative solution we can adopt, or we might have to bite the bullet and just do the whole shebang at some point.

  2. neumino commented on Jul 12, 2013

    @neumino
    Member

    I wrote how to set up a reverse proxy with apache in the new docs (it will be release Tuesday).

    I think we can also do it with a local htaccess. If we can, we should write it and provide it to people so they could secure they their web admin with just copying a file.

  3. HorizonNet commented on Jul 12, 2013

    @HorizonNet
    Author

    Alright, the solution with the reverse proxy should work for the time being.

  4. neumino commented on Jul 12, 2013

    @neumino
    Member

    @HorizonNet if that can help you, here are some docs on how to set a reverse proxy with apache2.
    I haven't written how to do it with nginx yet.

    Secure the web interface

    You also have to make sure to protect access to the web interface. Run the following commands to ensure that the web interface can only be accessed from the local machine running RethinkDB:

    sudo iptables -A INPUT -i eth0 -p tcp --dport 8080 -j DROP
    sudo iptables -I INPUT -i eth0 -s 127.0.0.1 -p tcp --dport 8080 -j ACCEPT
    

    You can also use apache to allow access (with a basic authentication) to the web interface from other machines:

    sudo apt-get install libapache2-mod-proxy-html
    sudo a2enmod proxy
    sudo a2enmod proxy_http
    

    Then create a new virtual host:

    <VirtualHost *:80>
        ServerName domain.net
    
        ProxyRequests Off
    
        <Proxy *>
            Order deny,allow
            Allow from all
            AuthType Basic
            AuthName "Password Required"
            AuthUserFile password.file
            AuthGroupFile group.file
            Require group dbadmin
        </Proxy>
    
        ProxyErrorOverride On
        ProxyPass   /rethinkdb_admin/   http://localhost:8080/
        ProxyPassReverse   /rethinkdb_admin/   http://localhost:8080/
    
    </VirtualHost>
    

    Create the password file in /etc/apache2/:

    htpasswd.exe -c password.file username
    

    Then create a file group.file with this content:

    dbadmin: username
    

    You can now access the web interface with http://<ip_machine>/rethinkdb_admin.

  5. elithrar commented on Jul 20, 2013

    @elithrar

    This should do the trick for nginx (tested on v1.1.19 on Ubuntu 12.04). The iptables requirements are the same as @neumino has above.

    server {
         listen 80;
         server_name domain.com;
    
         location /rethinkdb-admin/ {
    
              auth_basic "Restricted";
              auth_basic_user_file     /etc/nginx/.rethinkdb.pass;
              proxy_pass http://127.0.0.1:8080/;
              proxy_redirect off;
              proxy_set_header Authorization "";
         }
    }
    

    You can also set groups (ala the Apache config) with the auth_digest module (if you so choose). You will also want to grab apache2utils for the htpasswd utility, which nginx can leverage as well.

  6. mglukhovsky commented on Jul 20, 2013

    @mglukhovsky
    Member

    Thanks for the nginx config, @elithrar!

  7. neumino commented on Jul 20, 2013

    @neumino
    Member

    @elithrar you are awesome! Thanks!

  8. Someguy123 commented on Sep 15, 2013

    @Someguy123

    Why not just use an SSH tunnel? that's secure..
    ssh -L 8080:127.0.0.1:8080 user@yourserver
    Tadah, now just access the admin interface as normal from your own browser.

  9. rnhmjoj commented on Nov 23, 2013

    @rnhmjoj

    @neumino I tried your configuration but I have a problem.
    Apache can't load the resources because it is looking for them inside DocumentRoot while they are in /usr/local/share/rethinkdb/web.

  10. neumino commented on Nov 23, 2013

    @neumino
    Member

    @rnhmjoj there shouldn't be any document root.

    Can you load index.html?
    If I would guess, the problem would be that you have a conflict between multiple virtual host.

    I removed apache from my machine, give me a few minutes to re-install it and try the config.

  11. rnhmjoj commented on Nov 23, 2013

    @rnhmjoj

    @neumino The page is loaded but not the external files.
    In apache error_log, for example, there is: File does not exist: /Users/Michele/Sites/cluster.css, referer: https://localhost/rethinkdb.

  12. neumino commented on Nov 23, 2013

    @neumino
    Member

    @rnhmjoj sorry for the delay.

    I just tried the configuration with apache 2.2.25-1, it works fine for me.
    Does http://localhost:8080 works for you?

    The reverse proxy should forward everything, so if it can find index.html, it should also find the cluster.css fle.

    /Users/<user>/Sites is the default virtual host used on OSX when you install apache.
    Could you deactivate this virtualhost?

    The strange thing, is that localhost/rethinkdb_admin/ shouldn't try to reach localhost/cluster.css (I just checked, the path are relative, not absolute in index.html). Which lead to this question: What version of RethinkDB are you running?

  13. rnhmjoj commented on Nov 23, 2013

    @rnhmjoj

    Yes, I can connect to the console from http://localhost:8080.
    I am using the virtual host specified in httpd-ssl.conf with https.
    Version is 1.10.1

  14. neumino commented on Nov 24, 2013

    @neumino
    Member

    @rnhmjoj Can you with Chrome go on http://localhost/rethinkdb_admin/,
    Then right click > view page source
    Copy everything and paste it here?

  15. neumino commented on Nov 24, 2013

    @neumino
    Member

    @rnhmjoj and http://localhost/rethinkdb_admin/cluster.css?v=1.10.1 returns a 404 error?

  16. rnhmjoj commented on Nov 24, 2013

    @rnhmjoj

    @neumino Yes. See this.

  17. neumino commented on Nov 24, 2013

    @neumino
    Member

    Hum, that's really strange.

    The only thing that I think of is: there is a virtualhost that matches http://localhost/rethinkdb_admin/cluster.css?v=1.10.1 before the proxy pass.

    Can you disable all the virtualhost (with a2dissite or by removing the symbolic link in /etc/apache2/sites-enabled except the one described here #1163 (comment)
    And make sure that there is no other virtualhost except the one with the proxy pass.
    Make sure that there is no DocumentRoot in the virtualhost that contains the proxy pass.

    If that still doesn't work, I really have no idea what's happening there.
    I would like to run more tests, but I don't have an OS X machine available here :( and it works fine on my linux.

  18. rnhmjoj commented on Nov 24, 2013

    @rnhmjoj

    Ops. It's my bad: I forgot the final /in ProxyPass /rethinkdb_admin/
    I am so sorry. Sorry for making you lose all this time

  19. neumino commented on Nov 24, 2013

    @neumino
    Member

    No problem at least it works now : )

  20. danielmewes commented on Oct 8, 2014

    @danielmewes
    Member

    Closing in favor of #3159.

  21. modified the milestones: moved, backlog on Oct 8, 2014
  22. modified the milestones: duplicate, moved on Oct 9, 2014
  23. uchuugaka commented on Mar 16, 2017

    @uchuugaka

    Is it still accurate that there is no built-in web (http/https) log in, just automatically the admin user?
    Yikes. That's a real gotcha.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions