Require authentication for Redis HA autoconfig#9
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 343d65b048
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| REDIS_PASSWORD="${MN_REDIS_PASSWORD:-}" | ||
| SENTINEL_USERNAME="${MN_REDIS_SENTINEL_USERNAME:-}" | ||
| SENTINEL_PASSWORD="${MN_REDIS_SENTINEL_PASSWORD:-}" | ||
| SENTINEL_PASSWORD="${MN_REDIS_SENTINEL_PASSWORD:-$REDIS_PASSWORD}" |
There was a problem hiding this comment.
Propagate the sentinel password fallback to runtime clients
When operators run scripts/redis_ha.sh join directly with only MN_REDIS_PASSWORD, this fallback makes the helper start Sentinel with requirepass using that password, but the Elixir Sentinel client still reads only MN_REDIS_SENTINEL_PASSWORD in lib/mirror_neuron/redis/sentinel.ex, and wrappers like scripts/cluster_cli.sh do not export the fallback added to start_cluster_node.sh. In that documented direct-helper/CLI path the runtime queries Sentinel unauthenticated and cannot resolve the primary, so the same fallback needs to live in shared runtime/client config or all Sentinel-mode wrappers.
Useful? React with 👍 / 👎.
Motivation
redis-serverand Sentinel bound to0.0.0.0withprotected-mode noand no default credentials, exposing the runtime persistence plane to network attackers.Description
MN_REDIS_PASSWORD(viaREDIS_PASSWORD) beforescripts/redis_ha.sh joinwill start Redis/Sentinel by addingrequire_join_credentialsand refusing to run unauthenticated listeners.MN_REDIS_SENTINEL_PASSWORDis unset, and propagate that inscripts/start_cluster_node.shwhen launching in Sentinel mode.--requirepassand--masterauthonce credential validation passes and write Sentinel config entriesrequirepassandsentinel sentinel-pass(with safe quoting viaredis_conf_quote).tests/unit/redis_ha_scripts_test.exsand updateREADME.mdto document the HA helper password requirement.Testing
mix formatsuccessfully to update formatting.bash -nforscripts/redis_ha.sh,scripts/test_redis_sentinel_ha.sh,scripts/test_redis_sentinel_two_box_ha.sh,scripts/start_cluster_node.sh, andscripts/cluster_cli.sh, and they passed.redis-server/redis-cliwrappers to verify thatjoinwithMN_REDIS_PASSWORD=shared-secretstarts Redis with--requirepass/--masterauth, generates a Sentinel config containingrequirepass/sentinel sentinel-pass, and thatsentinelreceives theSENTINEL SET ... auth-passcommand, all of which succeeded.joinwithoutMN_REDIS_PASSWORDexits non-zero and does not start Redis/Sentinel, which also succeeded;mix testcould not be run in this environment because fetching Hex/dependencies was blocked by network restrictions (HTTP 403).Codex Task