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