root: support redis username (#8935)

This commit is contained in:
Jens L
2024-03-18 12:44:38 +01:00
committed by GitHub
parent 82ac7d195d
commit 104e70c383
3 changed files with 7 additions and 4 deletions

View File

@ -196,8 +196,10 @@ if CONFIG.get_bool("redis.tls", False):
_redis_protocol_prefix = "rediss://" _redis_protocol_prefix = "rediss://"
_redis_celery_tls_requirements = f"?ssl_cert_reqs={CONFIG.get('redis.tls_reqs')}" _redis_celery_tls_requirements = f"?ssl_cert_reqs={CONFIG.get('redis.tls_reqs')}"
_redis_url = ( _redis_url = (
f"{_redis_protocol_prefix}:" f"{_redis_protocol_prefix}"
f"{quote_plus(CONFIG.get('redis.password'))}@{quote_plus(CONFIG.get('redis.host'))}:" f"{quote_plus(CONFIG.get('redis.username'))}:"
f"{quote_plus(CONFIG.get('redis.password'))}@"
f"{quote_plus(CONFIG.get('redis.host'))}:"
f"{CONFIG.get_int('redis.port')}" f"{CONFIG.get_int('redis.port')}"
) )

View File

@ -32,8 +32,8 @@ func (a *Application) getStore(p api.ProxyOutpostConfig, externalHost *url.URL)
} }
if a.isEmbedded { if a.isEmbedded {
client := redis.NewClient(&redis.Options{ client := redis.NewClient(&redis.Options{
Addr: fmt.Sprintf("%s:%d", config.Get().Redis.Host, config.Get().Redis.Port), Addr: fmt.Sprintf("%s:%d", config.Get().Redis.Host, config.Get().Redis.Port),
// Username: config.Get().Redis.Password, Username: config.Get().Redis.Username,
Password: config.Get().Redis.Password, Password: config.Get().Redis.Password,
DB: config.Get().Redis.DB, DB: config.Get().Redis.DB,
}) })

View File

@ -116,6 +116,7 @@ class Migration(BaseMigration):
host=CONFIG.get("redis.host"), host=CONFIG.get("redis.host"),
port=6379, port=6379,
db=db, db=db,
username=CONFIG.get("redis.username"),
password=CONFIG.get("redis.password"), password=CONFIG.get("redis.password"),
) )
redis.flushall() redis.flushall()