feat: add validation of acl users (#1743)

* add validation for categories
* add tests
This commit is contained in:
Kostas Kyrimis 2023-08-29 18:52:46 +03:00 committed by GitHub
parent 2881ca99e4
commit 7c43cbf2b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 182 additions and 18 deletions

View 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