2020-03-07 17:37:38 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Access/EnabledRoles.h>
|
|
|
|
#include <Poco/ExpireCache.h>
|
2020-04-29 19:35:56 +00:00
|
|
|
#include <boost/container/flat_set.hpp>
|
2020-03-07 17:37:38 +00:00
|
|
|
#include <map>
|
|
|
|
#include <mutex>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
class AccessControlManager;
|
|
|
|
struct Role;
|
|
|
|
using RolePtr = std::shared_ptr<const Role>;
|
|
|
|
|
|
|
|
class RoleCache
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RoleCache(const AccessControlManager & manager_);
|
|
|
|
~RoleCache();
|
|
|
|
|
2020-04-29 19:35:56 +00:00
|
|
|
std::shared_ptr<const EnabledRoles> getEnabledRoles(
|
2021-02-26 22:37:00 +00:00
|
|
|
const std::vector<UUID> & current_roles,
|
|
|
|
const std::vector<UUID> & current_roles_with_admin_option);
|
2020-03-07 17:37:38 +00:00
|
|
|
|
|
|
|
private:
|
2021-06-15 19:55:21 +00:00
|
|
|
void collectEnabledRoles(scope_guard & notifications);
|
|
|
|
void collectEnabledRoles(EnabledRoles & enabled, scope_guard & notifications);
|
2020-03-07 17:37:38 +00:00
|
|
|
RolePtr getRole(const UUID & role_id);
|
|
|
|
void roleChanged(const UUID & role_id, const RolePtr & changed_role);
|
|
|
|
void roleRemoved(const UUID & role_id);
|
|
|
|
|
|
|
|
const AccessControlManager & manager;
|
2021-06-15 19:55:21 +00:00
|
|
|
Poco::ExpireCache<UUID, std::pair<RolePtr, scope_guard>> cache;
|
2020-03-07 17:37:38 +00:00
|
|
|
std::map<EnabledRoles::Params, std::weak_ptr<EnabledRoles>> enabled_roles;
|
|
|
|
mutable std::mutex mutex;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|