Skip to content

Commit

Permalink
add username option to redis config
Browse files Browse the repository at this point in the history
  • Loading branch information
charris82 authored and aleksihakli committed Jun 6, 2022
1 parent 0b96c53 commit bb122f2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions defender/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def get_redis_connection():
host=redis_config.get("HOST"),
port=redis_config.get("PORT"),
db=redis_config.get("DB"),
username=redis_config.get("USERNAME"),
password=redis_config.get("PASSWORD"),
ssl=redis_config.get("SSL"),
)
Expand All @@ -49,6 +50,7 @@ def parse_redis_url(url, password_quote=None):
# create config with some sane defaults
redis_config = {
"DB": 0,
"USERNAME": "default",
"PASSWORD": None,
"HOST": "localhost",
"PORT": 6379,
Expand All @@ -72,6 +74,8 @@ def parse_redis_url(url, password_quote=None):
redis_config.update({"PASSWORD": password})
if url.hostname:
redis_config.update({"HOST": url.hostname})
if url.username:
redis_config.update({"USERNAME": url.username})
if url.port:
redis_config.update({"PORT": int(url.port)})
if url.scheme in ["https", "rediss"]:
Expand Down

0 comments on commit bb122f2

Please sign in to comment.