From a1f91ffa180ad109917ef35d75dea5569b3022d5 Mon Sep 17 00:00:00 2001 From: Hwang Si Yeon <46290941+lowgiant@users.noreply.github.com> Date: Sun, 19 Nov 2023 22:09:14 +0900 Subject: [PATCH] Add an explanation for URI with -u in redis-cli --help (#12751) Add documentation of the URI format in the `--help` output of `redis-cli` and `redis-benchmark`. In particular, it's good for users to know that they need to specify "default" as the username when authenticating without a username. Other details of the URI format are described too, like scheme and dbnum. It used to be possible to connect to Redis using an URL with an empty username, like `redis-cli -u redis://:PASSWORD@localhost:6379/0`. This was broken in 6.2 (#8048), and there was a discussion about it #9186. Now, users need to specify "default" as the username and it's better to document it. Refer to #12746 for more details. --- src/redis-benchmark.c | 5 ++++- src/redis-cli.c | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/redis-benchmark.c b/src/redis-benchmark.c index ed53dcd33..ac2a313e8 100644 --- a/src/redis-benchmark.c +++ b/src/redis-benchmark.c @@ -1613,7 +1613,10 @@ usage: " -s Server socket (overrides host and port)\n" " -a Password for Redis Auth\n" " --user Used to send ACL style 'AUTH username pass'. Needs -a.\n" -" -u Server URI.\n" +" -u Server URI on format redis://user:password@host:port/dbnum\n" +" User, password and dbnum are optional. For authentication\n" +" without a username, use username 'default'. For TLS, use\n" +" the scheme 'rediss'.\n" " -c Number of parallel connections (default 50).\n" " Note: If --cluster is used then number of clients has to be\n" " the same or higher than the number of nodes.\n" diff --git a/src/redis-cli.c b/src/redis-cli.c index 0177effa2..b1b651ea6 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -3028,7 +3028,10 @@ static void usage(int err) { " --askpass Force user to input password with mask from STDIN.\n" " If this argument is used, '-a' and " REDIS_CLI_AUTH_ENV "\n" " environment variable will be ignored.\n" -" -u Server URI.\n" +" -u Server URI on format redis://user:password@host:port/dbnum\n" +" User, password and dbnum are optional. For authentication\n" +" without a username, use username 'default'. For TLS, use\n" +" the scheme 'rediss'.\n" " -r Execute specified command N times.\n" " -i When -r is used, waits seconds per command.\n" " It is possible to specify sub-second times like -i 0.1.\n" @@ -3113,6 +3116,7 @@ version,tls_usage); " Use --cluster help to list all available cluster manager commands.\n" "\n" "Examples:\n" +" redis-cli -u redis://default:PASSWORD@localhost:6379/0\n" " cat /etc/passwd | redis-cli -x set mypasswd\n" " redis-cli -D \"\" --raw dump key > key.dump && redis-cli -X dump_tag restore key2 0 dump_tag replace < key.dump\n" " redis-cli -r 100 lpush mylist x\n"