@@ -18,7 +18,7 @@ extern std::unique_ptr<PikaCmdTableManager> g_pika_cmd_table_manager;
1818
1919// class User
2020
21- User::User (const std::string& name) : name_(name) {
21+ User::User ( std::string name) : name_(std::move( name) ) {
2222 selectors_.emplace_back (std::make_shared<AclSelector>(static_cast <uint32_t >(AclSelectorFlag::ROOT )));
2323}
2424
@@ -157,6 +157,7 @@ pstd::Status User::CreateSelectorFromOpSet(const std::string& opSet) {
157157 return status;
158158 }
159159 AddSelector (selector);
160+ return status;
160161}
161162
162163std::shared_ptr<AclSelector> User::GetRootSelector () {
@@ -255,12 +256,8 @@ void User::GetUserDescribe(CmdRes* res) {
255256AclDeniedCmd User::CheckUserPermission (std::shared_ptr<Cmd>& cmd, const PikaCmdArgsType& argv) {
256257 std::shared_lock l (mutex_);
257258
258- if (!cmd->CheckArg (argv.size ())) {
259- return AclDeniedCmd::NUMBER ;
260- }
261259 std::string subCmd = " " ;
262- std::vector<std::string> keys;
263-
260+ auto keys = cmd->current_key ();
264261 AclDeniedCmd res = AclDeniedCmd::OK ;
265262 for (const auto & selector : selectors_) {
266263 res = selector->CheckCanExecCmd (cmd, subCmd, keys);
@@ -453,7 +450,7 @@ void Acl::UpdateDefaultUserPassword(const std::string& pass) {
453450 }
454451}
455452
456- bool Acl::CheckUserCanExec (const std::shared_ptr<Cmd>& cmd, const PikaCmdArgsType& argv) { cmd->name (); }
453+ // bool Acl::CheckUserCanExec(const std::shared_ptr<Cmd>& cmd, const PikaCmdArgsType& argv) { cmd->name(); }
457454
458455std::shared_ptr<User> Acl::CreateDefaultUser () {
459456 auto defaultUser = std::make_shared<User>(DefaultUser);
@@ -545,7 +542,7 @@ std::shared_ptr<User> Acl::Auth(const std::string& userName, const std::string&
545542 if (!user) {
546543 return nullptr ;
547544 }
548- if (user->MatchPassword (password)) {
545+ if (user->MatchPassword (pstd::sha256 ( password) )) {
549546 return user;
550547 }
551548 return nullptr ;
@@ -858,21 +855,17 @@ pstd::Status AclSelector::ChangeSelector(const std::shared_ptr<Cmd>& cmd, const
858855 return pstd::Status::OK ();
859856}
860857
861- void AclSelector::SetSubCommand (const uint32_t cmdId) { subCommand_[cmdId] = ~0 ; }
858+ void AclSelector::SetSubCommand (uint32_t cmdId) { subCommand_[cmdId] = ~0 ; }
862859
863- void AclSelector::SetSubCommand (const uint32_t cmdId, const uint32_t subCmdIndex) {
864- subCommand_[cmdId] = (1 << subCmdIndex);
865- }
860+ void AclSelector::SetSubCommand (uint32_t cmdId, uint32_t subCmdIndex) { subCommand_[cmdId] = (1 << subCmdIndex); }
866861
867862void AclSelector::ResetSubCommand () { subCommand_.clear (); }
868863
869- void AclSelector::ResetSubCommand (const uint32_t cmdId) { subCommand_[cmdId] = 0 ; }
864+ void AclSelector::ResetSubCommand (uint32_t cmdId) { subCommand_[cmdId] = 0 ; }
870865
871- void AclSelector::ResetSubCommand (const uint32_t cmdId, const uint32_t subCmdIndex) {
872- subCommand_[cmdId] = ~(1 << subCmdIndex);
873- }
866+ void AclSelector::ResetSubCommand (uint32_t cmdId, uint32_t subCmdIndex) { subCommand_[cmdId] = ~(1 << subCmdIndex); }
874867
875- bool AclSelector::CheckSubCommand (const uint32_t cmdId, const uint32_t subCmdIndex) {
868+ bool AclSelector::CheckSubCommand (uint32_t cmdId, uint32_t subCmdIndex) {
876869 if (subCmdIndex < 0 ) {
877870 return false ;
878871 }
@@ -1061,7 +1054,7 @@ void AclSelector::RemoveCommonRule(const std::string& rule) {
10611054
10621055 if (start > 0 ) { // the rule not included '-'/'+', but need delete need
10631056 --start;
1064- ++delNum; // star position moved one forward So delNum takes +1
1057+ ++delNum; // star position moved one forward So delNum takes +1
10651058 }
10661059
10671060 commandRules_.erase (start, delNum);
0 commit comments