Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Password doens't get passed down to redis cluster members #1462

Open
anlutro opened this issue Jun 5, 2024 · 0 comments
Open

Password doens't get passed down to redis cluster members #1462

anlutro opened this issue Jun 5, 2024 · 0 comments
Labels

Comments

@anlutro
Copy link

anlutro commented Jun 5, 2024

We're using GCP Memorystore Redis Cluster. The way this works is you know its main IP and connect on port 6379, but may be MOVED to another arbitrary IP/port. We don't know the members of the cluster up-front, and rely on CLUSTER SHARDS to find the members of the cluster.

This works fine with predis, unless we need to authenticate. It seems like whenever there's a MOVED response from the Redis server, the newly created connection loses its password attribute.

To Reproduce

  1. Set up a Redis Cluster which requires password authentication.
  2. Run the PHP code snippet below. It may work some of the times, but will fail other times.
<?php
require 'vendor/autoload.php';
// this only works in GCE/GKE, but bug should be reproducible with any arbitrary password
$ch = curl_init("http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token");
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Metadata-Flavor: Google"]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true)
$token = json_decode(curl_exec($ch))->access_token;

$client = new Predis\Client(
	[["proto" => "tcp", "host" => "redis-cluster", "port" => 6379, "password" => $token]],
	["cluster" => "redis", ["parameters" => ["password" => $token]]]
);
$client->set("tmp_test", "it works", "EX", 60);
echo $client->get("tmp_test");

Expected behavior
Connections instantiated by RedisCluster should take its password from $parameters["password"], or at least inherit the password attribute from the RedisCluster object itself.

Versions (please complete the following information):

  • Predis: 2.2.2
  • PHP 8.2.19
  • Redis Server 7.0.15 (according to redis-cli info, but it is GCP Memorystore)
  • Alpine Linux 3.19.1
@anlutro anlutro added the bug label Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant