humante/redis-browser

Auth after connection

Closed this issue · 2 comments

You can't connect to redis server with simple redis authentication.
http://redis.io/commands/auth

I patched RedisBrowser::Browser#redis to do auth if present in the config.

#..config/redis-browser.yml

connections:
  default:
    url: redis://127.0.0.1:6379/0
  production:
    host: <host>
    port: <port>
    auth: <auth>
# ../config/initializers/redis-browser.rb

module RedisBrowser
  class Browser
    def redis
      @redis ||= begin
        r = Redis.new(@conn)
        auth = @conn['auth']
        r.auth(auth) if auth
        r
      end
    end
  end
end

config = Rails.root.join('config','redis-browser.yml')
settings = YAML.load(ERB.new(IO.read(config)).result)
RedisBrowser.configure(settings)```