Skip to content

Commit

Permalink
Add support for TLS connections to redis
Browse files Browse the repository at this point in the history
  • Loading branch information
myoung34 committed Mar 5, 2018
1 parent 570187f commit 3cb82c4
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions redash/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
import urlparse
import urllib
import redis
from redis import StrictRedis
from flask import Flask, safe_join
from flask_sslify import SSLify
from werkzeug.contrib.fixers import ProxyFix
Expand Down Expand Up @@ -39,26 +39,7 @@ def setup_logging():

def create_redis_connection():
logging.debug("Creating Redis connection (%s)", settings.REDIS_URL)
redis_url = urlparse.urlparse(settings.REDIS_URL)

if redis_url.scheme == 'redis+socket':
qs = urlparse.parse_qs(redis_url.query)
if 'virtual_host' in qs:
db = qs['virtual_host'][0]
else:
db = 0

r = redis.StrictRedis(unix_socket_path=redis_url.path, db=db)
else:
if redis_url.path:
redis_db = redis_url.path[1]
else:
redis_db = 0
# Redis passwords might be quoted with special characters
redis_password = redis_url.password and urllib.unquote(redis_url.password)
r = redis.StrictRedis(host=redis_url.hostname, port=redis_url.port, db=redis_db, password=redis_password)

return r
return StrictRedis.from_url(settings.REDIS_URL)


setup_logging()
Expand Down

0 comments on commit 3cb82c4

Please sign in to comment.