Repository: traefik/traefik (language: go)

Issue:
Redis connect failed just show NOAUTH Authentication required
### Welcome!

- [X] Yes, I've searched similar issues on [GitHub](https://github.com/traefik/traefik/issues) and didn't find any.
- [X] Yes, I've searched similar issues on the [Traefik community forum](https://community.traefik.io) and didn't find any.

### What did you do?

I run new release version [v2.9.1](https://github.com/traefik/traefik/releases/tag/v2.9.1) [Latest](https://github.com/traefik/traefik/releases/latest)

It still has problem that can't login Redis with specified username & password

https://github.com/traefik/traefik/issues/9304
https://github.com/kvtools/redis/issues/3


### What did you see instead?


It does have to have an account and password,
but whether to provide a password or not, it always show
"KV connection error: KV store connection error: NOAUTH Authentication required..."

I write java test code, it login success, but Traefik failed

- https://lettuce.io/

```java
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.CountDownLatch;

import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.lettuce.core.RedisClient;
import io.lettuce.core.RedisURI;
import io.lettuce.core.codec.StringCodec;

class TestRedisClient {
    private static final Logger log = LoggerFactory.getLogger(TestRedisClient.class);

    @Test
    void test() {
        log.debug("Begin...");
        CountDownLatch latch = new CountDownLatch(1);
        try {
            String username = URLEncoder.encode("traefik-user", StandardCharsets.UTF_8);
            String password = URLEncoder.encode("~treafik-Test-109!", StandardCharsets.UTF_8);
            String connectionString = "redis://" + username + ":" + password
                    + "@redis-14654.c289.us-west-1-2.ec2.cloud.redislabs.com:14654/0";
            
            RedisURI redisURI = RedisURI.create(connectionString);

            RedisClient client = RedisClient.create();
            client.connectAsync(StringCodec.UTF8, redisURI)
                    .thenAccept(conn -> {
                        log.debug("onSuccess, conn: {}", conn);
                        conn.close();
                        latch.countDown();
                    })
                    .exceptionally(err -> {
                        log.error("onFailure", err);
                        latch.countDown();
                        return null;
                    });

            log.debug("Before await");
            latch.await();
            
            client.close();
            log.debug("After await");
        } catch (Exception e) {
            log.error(e.toString());
        } finally {
            log.debug("End.");
        }
    }
}
```



### What version of Traefik are you using?

[traefik_v2.9.1_windows_amd64.zip](https://github.com/traefik/traefik/releases/download/v2.9.1/traefik_v2.9.1_windows_amd64.zip)

```sh
D:\traefik>traefik version
2022/10/05 23:42:47 Datadog Tracer v1.38.1 WARN: Unable to load high precison timer, defaulting to time.Now()
Version:      2.9.1
Codename:     banon
Go version:   go1.19.1
Built:        2022-10-03T14:22:13Z
OS/Arch:      windows/amd64
```

### What is your environment & configuration?

 Here is test Account

```yaml
providers:
  redis: 
    rootKey: "traefik"
    username: "traefik-user"
    password: "~treafik-Test-109!"  
    endpoints:
      - "redis-14654.c289.us-west-1-2.ec2.cloud.redislabs.com:14654"
```


### If applicable, please paste the log output in DEBUG level



```sh
time="2022-10-05T21:20:47+08:00" level=info msg="Traefik version 2.9.1 built on 2022-10-03T14:22:13Z"
time="2022-10-05T21:20:47+08:00" level=info msg="\nStats collection is disabled.\nHelp us improve Traefik by turning this feature on :)\nMore details on: https://doc.traefik.io/traefik/contributing/data-collection/\n"
time="2022-10-05T21:20:47+08:00" level=info msg="Enabling ProxyProtocol without trusted IPs: Insecure" entryPointName=http
time="2022-10-05T21:20:47+08:00" level=info msg="Enabling ProxyProtocol without trusted IPs: Insecure" entryPointName=https
time="2022-10-05T21:20:47+08:00" level=info msg="Starting provider aggregator aggregator.ProviderAggregator"
time="2022-10-05T21:20:47+08:00" level=info msg="Starting provider *file.Provider"
time="2022-10-05T21:20:47+08:00" level=info msg="Starting provider *traefik.Provider"
time="2022-10-05T21:20:47+08:00" level=info msg="Starting provider *consulcatalog.Provider"
time="2022-10-05T21:20:47+08:00" level=info msg="Starting provider *acme.ChallengeTLSALPN"
time="2022-10-05T21:20:47+08:00" level=info msg="Starting provider *redis.Provider"
time="2022-10-05T21:20:48+08:00" level=error msg="KV connection error: KV store connection error: NOAUTH Authentication required, retrying in 525.860654ms" providerName=redis
time="2022-10-05T21:20:48+08:00" level=error msg="KV connection error: KV store connection error: NOAUTH Authentication required, retrying in 922.623964ms" providerName=redis
time="2022-10-05T21:20:49+08:00" level=error msg="KV connection error: KV store connection error: NOAUTH Authentication required, retrying in 1.542543566s" providerName=redis
time="2022-10-05T21:20:51+08:00" level=error msg="KV connection error: KV store connection error: NOAUTH Authentication required, retrying in 1.281710557s" providerName=redis
time="2022-10-05T21:20:52+08:00" level=error msg="KV connection error: KV store connection error: NOAUTH Authentication required, retrying in 2.089869192s" providerName=redis
time="2022-10-05T21:20:55+08:00" level=error msg="KV connection error: KV store connection error: NOAUTH Authentication required, retrying in 5.110286725s" providerName=redis
```


Discussion / hints:
Same here. I can confirm that in v2.8.8 the problem is not present.
in v2.8.8 the username was not supported -> #9304.
I'm looking for a `redis.conf` to reproduce the problem.
Here is a sample config file (My MacOS)

<details>
<summary>traefik.yml</summary>

```yaml
log:
  level: info
  filePath: "./log/traefik.log"

accessLog:
  filePath: "./log/access.log"
  bufferingSize: 100
  filters:    
    statusCodes:
      - "200"
      - "300-302"
    retryAttempts: true
    minDuration: "10ms"
  fields:
    defaultMode: keep
    names:
      ClientUsername: drop
    headers:
      defaultMode: keep
      names:
        User-Agent: redact
        Authorization: drop
        Content-Type: keep

providers:
  file:
    watch: true
    directory: "./conf"
    debugLogGeneratedTemplate: true
 
  redis: 
    rootKey: "traefik"
    username: "traefik-user"
    password: "~treafik-Test-109!"  
    endpoints:
      - "redis-14654.c289.us-west-1-2.ec2.cloud.redislabs.com:14654"

entryPoints:
  http: # web
    address: ":8181"
    forwardedHeaders:
      insecure: true
    proxyProtocol:
      insecure: true
    transport:
      respondingTimeouts:
        readTimeout: 60s  
    http:
      redirections:
        entryPoint:
          to: https
          scheme: https
          
  https:
    address: ":8443"
    proxyProtocol:
      insecure: true
    transport:
      respondingTimeouts:
        readTimeout: 60s

  traefik:
    address: ":8282"

api:
  insecure: true
  debug: true
  dashboard: true
```

</details>

<details>
<summary>traefik.log</summary>

```txt
time="2022-10-12T22:04:58+08:00" level=info msg="Traefik version 2.9.1 built on 2022-10-03T14:22:13Z"
time="2022-10-12T22:04:58+08:00" level=info msg="\nStats collection is disabled.\nHelp us improve Traefik by turning this feature on :)\nMore details on: https://doc.traefik.io/traefik/contributing/data-collection/\n"
time="2022-10-12T22:04:58+08:00" level=info msg="Enabling ProxyProtocol without trusted IPs: Insecure" entryPointName=http
time="2022-10-12T22:04:58+08:00" level=info msg="Enabling ProxyProtocol without trusted IPs: Insecure" entryPointName=https
time="2022-10-12T22:08:50+08:00" level=info msg="Traefik version 2.9.1 built on 2022-10-03T14:22:13Z"
time="2022-10-12T22:08:50+08:00" level=info msg="\nStats collection is disabled.\nHelp us improve Traefik by turning this feature on :)\nMore details on: https://doc.traefik.io/traefik/contributing/data-collection/\n"
time="2022-10-12T22:08:50+08:00" level=info msg="Enabling ProxyProtocol without trusted IPs: Insecure" entryPointName=http
time="2022-10-12T22:08:50+08:00" level=info msg="Enabling ProxyProtocol without trusted IPs: Insecure" entryPointName=https
time="2022-10-12T22:08:50+08:00" level=info msg="Starting provider aggregator aggregator.ProviderAggregator"
time="2022-10-12T22:08:50+08:00" level=info msg="Starting provider *file.Provider"
time="2022-10-12T22:08:50+08:00" level=info msg="Starting provider *traefik.Provider"
time="2022-10-12T22:08:50+08:00" level=info msg="Starting provider *acme.ChallengeTLSALPN"
time="2022-10-12T22:08:50+08:00" level=info msg="Starting provider *redis.Provider"
time="2022-10-12T22:08:50+08:00" level=error msg="KV connection error: KV store connection error: NOAUTH Authentication required, retrying in 619.568247ms" providerName=redis
time="2022-10-12T22:08:51+08:00" level=error msg="KV connection error: KV store connection error: NOAUTH Authentication required, retrying in 809.331073ms" providerName=redis
time="2022-10-12T22:08:52+08:00" level=error msg="KV connection error: KV store connection error: NOAUTH Authentication required, retrying in 1.098028431s" providerName=redis
time="2022-10-12T22:08:53+08:00" level=error msg="KV connection error: KV store connection error: NOAUTH Authentication required, retrying in 1.559602842s" providerName=redis
time="2022-10-12T22:08:55+08:00" level=error msg="KV connection error: KV store connection error: NOAUTH Authentication required, retrying in 3.066236807s" providerName=redis
```

</details>

<details>
<summary>Step By Step</summary>

```sh
### Mac

sudo mkdir /opt/traefik-test
sudo chown -R $(whoami) /opt/traefik-test
sudo chmod +wrx /opt/traefik-test

cd /opt/traefik-test

wget https://github.com/traefik/traefik/releases/download/v2.9.1/traefik_v2.9.1_darwin_amd64.tar.gz

tar -zxvf ./traefik_v2.9.1_darwin_amd64.tar.gz
rm -f ./traefik_v2.9.1_darwin_amd64.tar.gz

sudo mkdir /opt/traefik-test/conf
sudo chown -R $(whoami) /opt/traefik-test/conf
sudo chmod +wr /opt/traefik-test/conf

cp -r $HOME/.../traefik.yml ./conf/

sudo mkdir /opt/traefik-test/log
sudo chown -R $(whoami) /opt/traefik-test/log
sudo chmod +wr /opt/traefik-test/log

sudo ./traefik --configFile=/opt/traefik-test/conf/traefik.yml

ps -ef | grep traefik
netstat -ant | grep 8181
netstat -ant | grep 8282
netstat -ant | grep 8443

curl -v -w "\n" http://127.0.0.1:8282

tail -200f /opt/traefik-test/log/traefik.log
tail -200f /opt/traefik-test/log/access.log

```

</details>



Redis GUI tool login screenshot
- https://redis.com/redis-enterprise/redis-insight/

<details>

<img width="606" alt="截圖 2022-10-12 22 32 15" src="https://user-images.githubusercontent.com/1053138/195372209-8b91d7eb-13ce-448a-b941-5e741ffde8d1.png">

</details>

<details>

<img width="981" alt="截圖 2022-10-12 22 34 09" src="https://user-images.githubusercontent.com/1053138/195372373-d644f8e1-59e1-4a69-9ce3-7a9c23c252b2.png">

</details>

I don't have Redis Enterprise, I just have the open-source version, so I'm looking for a `redis.conf` file.

<details>
<summary>redis.conf</summary>

```yaml
#protected-mode no
requirepass "_default_pwd~"

user traefik-user on >~treafik-Test-109! ~* +@all
```

</details>

<details>
<summary>Step by step</summary>

```sh
sudo mkdir /opt/redis-test
sudo chown -R $(whoami) /opt/redis-test
sudo chmod +wr /opt/redis-test

cd /opt/redis-test
cp -r $HOME/.../redis.conf /opt/redis-test

docker run -v /opt/redis-test:/usr/local/etc/redis -d --name redis-test -p 14654:6379 --restart always redis:6 /usr/local/etc/redis/redis.conf
```

</details>


<details>
<summary>traefik.yml</summary>

```yaml
# ...
providers:
  file:
    watch: true
    directory: "./conf"
    debugLogGeneratedTemplate: true
 
  redis: 
    rootKey: "traefik"
    username: "traefik-user"
    password: "~treafik-Test-109!"  
    endpoints:
      #- "redis-14654.c289.us-west-1-2.ec2.cloud.redislabs.com:14654"
      - "127.0.0.1:14654"
# ...
```

</details>

<details>
<summary>Make sure endpoint "Endpoint:127.0.0.1:14654" login  required AUTH</summary>

- screenshot

<img width="562" alt="截圖 2022-10-13 06 58 16" src="https://user-images.githubusercontent.com/1053138/195463825-79c66828-fd78-4a24-bf20-791e6dfc71b5.png">

<img width="877" alt="截圖 2022-10-13 07 08 58" src="https://user-images.githubusercontent.com/1053138/195464220-901a4cf8-2777-4eed-8182-df2e856bd78f.png">


</details>


GUI Tool  login default user success, traefik login failed

<details>

```yaml
providers:
  # ...
  redis: 
    rootKey: "traefik"
    #username: "traefik-user"
    #password: "~treafik-Test-109!"
    username: "default"
    password: "_default_pwd~"
    endpoints:
      - "127.0.0.1:14654"
  #...
```

</details>


<details>

<img width="730" alt="截圖 2022-10-13 07 34 03" src="https://user-images.githubusercontent.com/1053138/195466697-c781436d-5e1c-47ca-a08c-fbf05ac70eb0.png">

</details>


Fix patch:
diff --git a/go.mod b/go.mod
index 0ba8a8b892..a153b1af6a 100644
--- a/go.mod
+++ b/go.mod
@@ -36,11 +36,11 @@ require (
 	github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d
 	github.com/instana/go-sensor v1.38.3
 	github.com/klauspost/compress v1.14.2
-	github.com/kvtools/consul v1.0.1
-	github.com/kvtools/etcdv3 v1.0.1
-	github.com/kvtools/redis v1.0.1
+	github.com/kvtools/consul v1.0.2
+	github.com/kvtools/etcdv3 v1.0.2
+	github.com/kvtools/redis v1.0.2
 	github.com/kvtools/valkeyrie v1.0.0
-	github.com/kvtools/zookeeper v1.0.1
+	github.com/kvtools/zookeeper v1.0.2
 	github.com/lucas-clemente/quic-go v0.28.1
 	github.com/mailgun/ttlmap v0.0.0-20170619185759-c1c17f74874f
 	github.com/miekg/dns v1.1.50
diff --git a/go.sum b/go.sum
index a557a82b51..c644b5edc0 100644
--- a/go.sum
+++ b/go.sum
@@ -1299,16 +1299,16 @@ github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
 github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
 github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
 github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
-github.com/kvtools/consul v1.0.1 h1:RHwW0qTPL8Gwb+ueH6kpAIZ3fuNnSdAZaydfKjMIr/4=
-github.com/kvtools/consul v1.0.1/go.mod h1:bFnzfGJ5ZIRRXCBGBmwhJlLdEWOlrjOcS1WjyAQzaJA=
-github.com/kvtools/etcdv3 v1.0.1 h1:Ugr5ryI+FIeZQh0RCmtGFJptgSlbrVGjAnJWk9r//WI=
-github.com/kvtools/etcdv3 v1.0.1/go.mod h1:Xr6DbwqjuCEcXAIWmXxw0DX+N5BhuvablXgN90XeqMM=
-github.com/kvtools/redis v1.0.1 h1:vtLE3D3xfMbXfenRGuclDU8pe64OiqcBMmKm2RY4Wuo=
-github.com/kvtools/redis v1.0.1/go.mod h1:wuUNwwKOHi2TYxDxj1sGF74Jdg0jywydnatXtnOR3hA=
+github.com/kvtools/consul v1.0.2 h1:ltPgs4Ld09Xaa7zrOJ/TewBYKAsr11/LRFpErdkb8AA=
+github.com/kvtools/consul v1.0.2/go.mod h1:bFnzfGJ5ZIRRXCBGBmwhJlLdEWOlrjOcS1WjyAQzaJA=
+github.com/kvtools/etcdv3 v1.0.2 h1:EB0mAtzqe1folE7m7Q6wnCXcGwaOmrYmsVmF3hNsTKI=
+github.com/kvtools/etcdv3 v1.0.2/go.mod h1:Xr6DbwqjuCEcXAIWmXxw0DX+N5BhuvablXgN90XeqMM=
+github.com/kvtools/redis v1.0.2 h1:D3GjGGtssJF2w8mniWtIxcT/YX9YnRc4jNCm0hrVygQ=
+github.com/kvtools/redis v1.0.2/go.mod h1:wuUNwwKOHi2TYxDxj1sGF74Jdg0jywydnatXtnOR3hA=
 github.com/kvtools/valkeyrie v1.0.0 h1:LAITop2wPoYCMitR24GZZsW0b57hmI+ePD18VRTtOf0=
 github.com/kvtools/valkeyrie v1.0.0/go.mod h1:bDi/OdhJCSbGPMsCgUQl881yuEweKCSItAtTBI+ZjpU=
-github.com/kvtools/zookeeper v1.0.1 h1:CBKNOuesj4CgW5PisK2jVx1+XP+T51bVgYHrZPQL5OM=
-github.com/kvtools/zookeeper v1.0.1/go.mod h1:6TfxUwJ7IuBk5srgnoe528W0ftanNECHgOiShx/t0Aw=
+github.com/kvtools/zookeeper v1.0.2 h1:uK0CzQa+mtKGxDDH+DeqXo2HC1Kx4hWXZ7pX/zS4aTo=
+github.com/kvtools/zookeeper v1.0.2/go.mod h1:6TfxUwJ7IuBk5srgnoe528W0ftanNECHgOiShx/t0Aw=
 github.com/kylelemons/go-gypsy v0.0.0-20160905020020-08cad365cd28/go.mod h1:T/T7jsxVqf9k/zYOqbgNAsANsjxTd1Yq3htjDhQ1H0c=
 github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
 github.com/labbsr0x/bindman-dns-webhook v1.0.2 h1:I7ITbmQPAVwrDdhd6dHKi+MYJTJqPCK0jE6YNBAevnk=
diff --git a/pkg/provider/kv/redis/redis.go b/pkg/provider/kv/redis/redis.go
index 546c93d940..23f432bb1e 100644
--- a/pkg/provider/kv/redis/redis.go
+++ b/pkg/provider/kv/redis/redis.go
@@ -30,7 +30,7 @@ func (p *Provider) SetDefaults() {
 
 // Init the provider.
 func (p *Provider) Init() error {
-	config := redis.Config{
+	config := &redis.Config{
 		Username: p.Username,
 		Password: p.Password,
 		DB:       p.DB,


Test patch: