8000 Redis Cache not working with user and password (only work when user setted) · Issue #47303 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Redis Cache not working with user and password (only work when user setted) #47303

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

Closed
cedriclombardot opened this issue Aug 17, 2022 · 2 comments

Comments

@cedriclombardot
Copy link
Contributor
cedriclombardot commented Aug 17, 2022

Symfony version(s) affected

6.0.*

Description

When we use a default_redis_provider with password

Like rediss://<user>:<pass>@<host>:<port>/<path>

The RedisTrait initializer will failed with a WRONGPASS because at line 214 the $redis->auth($auth) is only called with password instead of user and password

How to reproduce

See Description

Possible Solution

Change line 97

        $params = preg_replace_callback('#^'.$scheme.':(//)?(?:(?:[^:@]*+:)?([^@]*+)@)?#', function ($m) use (&$auth) {
            if (isset($m[2])) {
                $auth = $m[2];

                if ('' === $auth) {
                    $auth = null;
                }
            }

            return 'file:'.($m[1] ?? '');
        }, $dsn);

BY

$params = preg_replace_callback('#^'.$scheme.':(\/\/)?([^:@]*+)(?:(?:[^:@]*+:)?([^@]*+)@)?#', function ($m) use (&$auth) {
            if (isset($m[2])) {
                $auth = $m[2];

                if ('' === $auth) {
                    $auth = null;
                }

                if (isset($m[3])) {
                    $auth = [ $auth, $m[3] ];
                }
            }

            return 'file:'.($m[1] ?? '');
        }, $dsn);

Additional Context

Warning the fix not working completly for other paths

@MatTheCat
Copy link
Contributor
< 923A tr class="d-block">

You can upgrade to 6.1 😉

#45313

@cedriclombardot
Copy link
Contributor Author
cedriclombardot commented Aug 17, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
0