StackExchange / StackExchange.Redis

General purpose redis client
https://stackexchange.github.io/StackExchange.Redis/
Other
5.91k stars 1.51k forks source link

Authentication failure when different passwords are used for sentinel and redis #1698

Open rmkm4 opened 3 years ago

rmkm4 commented 3 years ago

I am receiving below error when sentinel and redis are configured with different passwords. Is there a workaround to overcome this error ?

It was not possible to connect to the redis server(s). There was an authentication failure; check that passwords (or client certificates) are configured correctly. AuthenticationFailure (None, last-recv: 34) on 10.33.190.74:6379/Interactive, Flushed/ComputeResult, last: ECHO, origin: SetResult, outstanding: 0, last-read: 0s ago, last-write: 0s ago, keep-alive: 60s, state: ConnectedEstablishing, mgr: 8 of 10 available, last-heartbeat: never, global: 0s ago, v: 2.2.4.27433

NickCraver commented 3 years ago

I don't think we support this right now - can you elaborate on your use case for needing 2 passwords, for the 2 connection layers?

minhnguyenvan95 commented 3 years ago

Hi @NickCraver I have same issue too, I don't know how to config Sentinel Password, We have 2 different password 1 for Sentinel, 1 for Redis

capcom923 commented 2 years ago

Hi @NickCraver I have the same issue. Do we have any progress?

BTW, Java already support this feature https://github.com/spring-projects/spring-boot/issues/21353

So, please help to priority this feature. Don't let us lose this game C# vs Java :)

Thanks,

NickCraver commented 2 years ago

I was looking at this, but it's not as trivial to change as it appears - needs more thought. See the problem is we don't know for sure it's a Sentinel until we connect, so inverse to normal reasoning (at least for me) of "SetinelUser, SentinelPassword" settings, you really have new settings for the child servers that sentinels return...or something. The relationship is very odd as a result of connecting and subsequently connecting downstream, needs more thought.

minhnguyenvan95 commented 2 years ago

thumbs up

christianerbsmehl commented 6 months ago

We also need this feature. We are using an anynines Redis instance on CloudFoundry, which provides different usernames and passwords for the sentinel and redis connection. @NickCraver could you please look into it? I think it should be possible now because there is a flag in the configuration (IsSentinel, checks for ServiceName to be set) which is checked before connection See https://github.com/StackExchange/StackExchange.Redis/blob/cb8b20df0e2975717bde97ce95ac20e8e8353572/src/StackExchange.Redis/ConnectionMultiplexer.cs#L685 So the subsequent calls to SentinelPrimaryConnect / ConnectImpl could retrieve different usernames / passwords from the ConfigurationOptions. To aviod breaking changes, we could add a SentinelUser and SentinelPassword to the ConfigurationOptions and fall back to User and Password if not provided. What do you think about that?