mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
feat(cmd): add restricted commands flag (#1967)
This commit is contained in:
parent
ba4eba991d
commit
e6b8cd1d76
5 changed files with 47 additions and 0 deletions
|
@ -821,6 +821,12 @@ std::optional<ErrorReply> Service::VerifyCommandState(const CommandId* cid, CmdA
|
|||
|
||||
ServerState& etl = *ServerState::tlocal();
|
||||
|
||||
// If there is no connection owner, it means the command it being called
|
||||
// from another command or used internally, therefore is always permitted.
|
||||
if (dfly_cntx.owner() != nullptr && !dfly_cntx.owner()->IsAdmin() && cid->IsRestricted()) {
|
||||
return ErrorReply{"Cannot execute restricted command (admin only)"};
|
||||
}
|
||||
|
||||
if (auto err = cid->Validate(tail_args); err)
|
||||
return err;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue