mirror of
https://github.com/fluencelabs/redis
synced 2025-03-30 22:31:03 +00:00
ACL: authCommand() refactored into ACLAuthenticateUser().
This commit is contained in:
parent
87594a7470
commit
36d1588215
20
src/acl.c
20
src/acl.c
@ -888,6 +888,22 @@ int ACLCheckUserCredentials(robj *username, robj *password) {
|
|||||||
return C_ERR;
|
return C_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This is like ACLCheckUserCredentials(), however if the user/pass
|
||||||
|
* are correct, the connection is put in authenticated state and the
|
||||||
|
* connection user reference is populated.
|
||||||
|
*
|
||||||
|
* The return value is C_OK or C_ERR with the same meaning as
|
||||||
|
* ACLCheckUserCredentials(). */
|
||||||
|
int ACLAuthenticateUser(client *c, robj *username, robj *password) {
|
||||||
|
if (ACLCheckUserCredentials(username,password) == C_OK) {
|
||||||
|
c->authenticated = 1;
|
||||||
|
c->user = ACLGetUserByName(username->ptr,sdslen(username->ptr));
|
||||||
|
return C_OK;
|
||||||
|
} else {
|
||||||
|
return C_ERR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* For ACL purposes, every user has a bitmap with the commands that such
|
/* For ACL purposes, every user has a bitmap with the commands that such
|
||||||
* user is allowed to execute. In order to populate the bitmap, every command
|
* user is allowed to execute. In order to populate the bitmap, every command
|
||||||
* should have an assigned ID (that is used to index the bitmap). This function
|
* should have an assigned ID (that is used to index the bitmap). This function
|
||||||
@ -1605,9 +1621,7 @@ void authCommand(client *c) {
|
|||||||
password = c->argv[2];
|
password = c->argv[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ACLCheckUserCredentials(username,password) == C_OK) {
|
if (ACLAuthenticateUser(c,username,password) == C_OK) {
|
||||||
c->authenticated = 1;
|
|
||||||
c->user = ACLGetUserByName(username->ptr,sdslen(username->ptr));
|
|
||||||
addReply(c,shared.ok);
|
addReply(c,shared.ok);
|
||||||
} else {
|
} else {
|
||||||
addReplyError(c,"-WRONGPASS invalid username-password pair");
|
addReplyError(c,"-WRONGPASS invalid username-password pair");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user