AUTH * AUTH (Redis >= 6.0 form) * * When the user is omitted it means that we are trying to authenticate * against the default user. */
| 2251 | * When the user is omitted it means that we are trying to authenticate |
| 2252 | * against the default user. */ |
| 2253 | void authCommand(client *c) { |
| 2254 | /* Only two or three argument forms are allowed. */ |
| 2255 | if (c->argc > 3) { |
| 2256 | addReplyErrorObject(c,shared.syntaxerr); |
| 2257 | return; |
| 2258 | } |
| 2259 | /* Always redact the second argument */ |
| 2260 | redactClientCommandArgument(c, 1); |
| 2261 | |
| 2262 | /* Handle the two different forms here. The form with two arguments |
| 2263 | * will just use "default" as username. */ |
| 2264 | robj *username, *password; |
| 2265 | if (c->argc == 2) { |
| 2266 | /* Mimic the old behavior of giving an error for the two commands |
| 2267 | * from if no password is configured. */ |
| 2268 | if (DefaultUser->flags & USER_FLAG_NOPASS) { |
| 2269 | addReplyError(c,"AUTH <password> called without any password " |
| 2270 | "configured for the default user. Are you sure " |
| 2271 | "your configuration is correct?"); |
| 2272 | return; |
| 2273 | } |
| 2274 | |
| 2275 | username = shared.default_username; |
| 2276 | password = c->argv[1]; |
| 2277 | } else { |
| 2278 | username = c->argv[1]; |
| 2279 | password = c->argv[2]; |
| 2280 | redactClientCommandArgument(c, 2); |
| 2281 | } |
| 2282 | |
| 2283 | if (ACLAuthenticateUser(c,username,password) == C_OK) { |
| 2284 | addReply(c,shared.ok); |
| 2285 | } else { |
| 2286 | addReplyError(c,"-WRONGPASS invalid username-password pair or user is disabled."); |
| 2287 | } |
| 2288 | } |
| 2289 | |
| 2290 | /* Set the password for the "default" ACL user. This implements supports for |
| 2291 | * requirepass config, so passing in NULL will set the user to be nopass. */ |
nothing calls this directly
no test coverage detected