mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 18:35:46 +02:00
feat: add validation of acl users (#1743)
* add validation for categories * add tests
This commit is contained in:
parent
2881ca99e4
commit
7c43cbf2b5
9 changed files with 182 additions and 18 deletions
19
src/server/acl/validator.cc
Normal file
19
src/server/acl/validator.cc
Normal file
|
@ -0,0 +1,19 @@
|
|||
// Copyright 2023, DragonflyDB authors. All rights reserved.
|
||||
// See LICENSE for licensing terms.
|
||||
//
|
||||
|
||||
#include "server/acl/validator.h"
|
||||
|
||||
#include "server/server_state.h"
|
||||
|
||||
namespace dfly::acl {
|
||||
|
||||
[[nodiscard]] bool IsUserAllowedToInvokeCommand(const ConnectionContext& cntx,
|
||||
const facade::CommandId& id) {
|
||||
auto& registry = *ServerState::tlocal()->user_registry;
|
||||
auto credentials = registry.GetCredentials(cntx.authed_username);
|
||||
auto command_credentials = id.acl_categories();
|
||||
return (credentials.acl_categories & command_credentials) != 0;
|
||||
}
|
||||
|
||||
} // namespace dfly::acl
|
Loading…
Add table
Add a link
Reference in a new issue