mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-23 18:04:34 +00:00
feat: add ssl mode with non url connection + add redis cluster support (#494)
This commit is contained in:
committed by
GitHub
parent
416a4660ae
commit
e529e00fd7
@@ -13,6 +13,14 @@ The storage of sessions in Redis is activated using environment variables.
|
||||
* ``ODOO_SESSION_REDIS_PORT`` is the redis port (default is ``6379``)
|
||||
* ``ODOO_SESSION_REDIS_PASSWORD`` is the password for the AUTH command
|
||||
(optional)
|
||||
* ``ODOO_SESSION_REDIS_SSL`` is the SSL connection (default is ``true``)
|
||||
(optional)
|
||||
* ``ODOO_SESSION_REDIS_SSL_CERT_REQS`` is the SSL certificate requirements (default is
|
||||
``required``), needed to be disabled when using self-signed certificates
|
||||
(optional)
|
||||
* ``ODOO_SESSION_REDIS_CLUSTER`` the redis in cluster mode (default is ``false``)
|
||||
(optional)
|
||||
|
||||
* ``ODOO_SESSION_REDIS_URL`` is an alternative way to define the Redis server
|
||||
address. It's the preferred way when you're using the ``rediss://`` protocol.
|
||||
* ``ODOO_SESSION_REDIS_PREFIX`` is the prefix for the session keys (optional)
|
||||
|
||||
+15
-3
@@ -40,8 +40,10 @@ url = os.getenv("ODOO_SESSION_REDIS_URL")
|
||||
password = os.getenv("ODOO_SESSION_REDIS_PASSWORD")
|
||||
expiration = os.getenv("ODOO_SESSION_REDIS_EXPIRATION")
|
||||
anon_expiration = os.getenv("ODOO_SESSION_REDIS_EXPIRATION_ANONYMOUS")
|
||||
|
||||
|
||||
# For non url connections
|
||||
ssl = os.getenv("ODOO_SESSION_REDIS_SSL", "1")
|
||||
ssl_cert_reqs = os.getenv("ODOO_SESSION_REDIS_SSL_CERT_REQS", "1")
|
||||
redis_cluster = os.getenv("ODOO_SESSION_REDIS_CLUSTER", "0")
|
||||
@lazy_property
|
||||
def session_store(self):
|
||||
if sentinel_host:
|
||||
@@ -49,8 +51,18 @@ def session_store(self):
|
||||
redis_client = sentinel.master_for(sentinel_master_name)
|
||||
elif url:
|
||||
redis_client = redis.from_url(url)
|
||||
elif is_true(redis_cluster):
|
||||
redis_client = redis.RedisCluster(
|
||||
host=host,
|
||||
port=port,
|
||||
password=password,
|
||||
ssl=is_true(ssl),
|
||||
ssl_cert_reqs=is_true(ssl_cert_reqs))
|
||||
else:
|
||||
redis_client = redis.Redis(host=host, port=port, password=password)
|
||||
redis_client = redis.Redis(
|
||||
host=host, port=port, password=password,
|
||||
ssl=is_true(ssl),
|
||||
ssl_cert_reqs=is_true(ssl_cert_reqs))
|
||||
return RedisSessionStore(
|
||||
redis=redis_client,
|
||||
prefix=prefix,
|
||||
|
||||
Reference in New Issue
Block a user