From 0d4c8eb15a31d4b2b2006faecdd76f475b60408c Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sat, 24 Jan 2026 14:18:55 -0600 Subject: [PATCH] feat: add Redis password authentication support Add REDIS_PASSWORD environment variable support to both Phoenix.PubSub.Redis and Exq background job processor. Password is optional - if not set, connects without authentication. Changes: - application.ex: Add password to PubSub Redis config if REDIS_PASSWORD is set - exq_supervisor.ex: Add password to Exq Redis config if REDIS_PASSWORD is set Required for connecting to Proxmox-hosted Redis with authentication. --- lib/towerops/application.ex | 8 ++++++++ lib/towerops/exq_supervisor.ex | 9 ++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/towerops/application.ex b/lib/towerops/application.ex index 7e21d308..5170c5c6 100644 --- a/lib/towerops/application.ex +++ b/lib/towerops/application.ex @@ -117,6 +117,14 @@ defmodule Towerops.Application do node_name: node() ] + # Add password if configured + base_opts = + case System.get_env("REDIS_PASSWORD") do + nil -> base_opts + "" -> base_opts + password -> Keyword.put(base_opts, :password, password) + end + # Add resilience options for better reconnection handling resilience_opts = [ # Redix connection options for better resilience diff --git a/lib/towerops/exq_supervisor.ex b/lib/towerops/exq_supervisor.ex index cbf3281c..40f94a57 100644 --- a/lib/towerops/exq_supervisor.ex +++ b/lib/towerops/exq_supervisor.ex @@ -65,7 +65,7 @@ defmodule Towerops.ExqSupervisor do end defp build_exq_config(redis_config) do - [ + base_config = [ name: Exq, host: Keyword.get(redis_config, :host, "localhost"), port: Keyword.get(redis_config, :port, 6379), @@ -96,5 +96,12 @@ defmodule Towerops.ExqSupervisor do socket_opts: [keepalive: true] ] ] + + # Add password if configured + case System.get_env("REDIS_PASSWORD") do + nil -> base_config + "" -> base_config + password -> Keyword.put(base_config, :password, password) + end end end