Skip to content

Support redis:// URI scheme and ignore username for AUTH #40

@daneren2005

Description

@daneren2005

In the Factories parseUrl method, you are generating the auth param by combining the username and password. Redis as far as I am aware has no concept of users. A lot of connection strings just specify one because otherwise the password won't be parsed correctly by most tools. Ex: redis://anything:password@host:port.

It is an easy fix:

$auth = null;
if (isset($parts['user'])) {
    $auth = $parts['user'];
}
if (isset($parts['pass'])) {
    $auth .= ':' . $parts['pass'];
}
if ($auth !== null) {
    $parts['auth'] = $auth;
}

change to

if (isset($parts['pass'])) {
    $parts['auth'] = $parts['pass'];
}

I also am going to mention that redis:// is also a valid schema:

if ($parts === false || !isset($parts['host']) || $parts['scheme'] !== 'tcp') {
    throw new InvalidArgumentException('Given URL can not be parsed');
}

changes to

$validSchemes = array('redis', 'tcp');
if ($parts === false || !isset($parts['host']) || !in_array($parts['scheme'], $validSchemes)) {
    throw new InvalidArgumentException('Given URL can not be parsed');
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions