ClickHouse/dbms/src/Access/AccessControlManager.h

84 lines
2.3 KiB
C++
Raw Normal View History

#pragma once
#include <Access/MultipleAccessStorage.h>
#include <Poco/AutoPtr.h>
2019-11-04 19:17:27 +00:00
#include <memory>
namespace Poco
{
2019-11-04 19:17:27 +00:00
namespace Net
{
class IPAddress;
}
namespace Util
{
class AbstractConfiguration;
}
}
namespace DB
{
class AccessRightsContext;
using AccessRightsContextPtr = std::shared_ptr<const AccessRightsContext>;
2020-02-12 03:03:33 +00:00
class AccessRightsContextFactory;
2020-02-21 00:17:07 +00:00
struct User;
using UserPtr = std::shared_ptr<const User>;
2020-02-22 19:35:39 +00:00
class RoleContext;
2020-02-21 00:17:07 +00:00
using RoleContextPtr = std::shared_ptr<const RoleContext>;
class RoleContextFactory;
class RowPolicyContext;
using RowPolicyContextPtr = std::shared_ptr<const RowPolicyContext>;
class RowPolicyContextFactory;
2019-11-04 19:17:27 +00:00
class QuotaContext;
using QuotaContextPtr = std::shared_ptr<const QuotaContext>;
2019-11-04 19:17:27 +00:00
class QuotaContextFactory;
struct QuotaUsageInfo;
2020-01-12 21:00:55 +00:00
class ClientInfo;
struct Settings;
2019-11-04 19:17:27 +00:00
/// Manages access control entities.
class AccessControlManager : public MultipleAccessStorage
{
public:
AccessControlManager();
~AccessControlManager();
void setLocalDirectory(const String & directory);
void setUsersConfig(const Poco::Util::AbstractConfiguration & users_config);
2019-11-04 19:17:27 +00:00
2020-02-12 03:03:33 +00:00
AccessRightsContextPtr getAccessRightsContext(
2020-02-21 00:17:07 +00:00
const UUID & user_id,
const std::vector<UUID> & current_roles,
bool use_default_roles,
const Settings & settings,
const String & current_database,
const ClientInfo & client_info) const;
2020-01-12 21:00:55 +00:00
2020-02-21 00:17:07 +00:00
RoleContextPtr getRoleContext(
const std::vector<UUID> & current_roles,
const std::vector<UUID> & current_roles_with_admin_option) const;
RowPolicyContextPtr getRowPolicyContext(
const UUID & user_id,
const std::vector<UUID> & enabled_roles) const;
2019-11-04 19:17:27 +00:00
2020-02-12 03:03:33 +00:00
QuotaContextPtr getQuotaContext(
2020-02-21 00:17:07 +00:00
const String & user_name,
const UUID & user_id,
const std::vector<UUID> & enabled_roles,
const Poco::Net::IPAddress & address,
const String & custom_quota_key) const;
2020-02-12 03:03:33 +00:00
2019-11-04 19:17:27 +00:00
std::vector<QuotaUsageInfo> getQuotaUsageInfo() const;
private:
2020-02-12 03:03:33 +00:00
std::unique_ptr<AccessRightsContextFactory> access_rights_context_factory;
2020-02-21 00:17:07 +00:00
std::unique_ptr<RoleContextFactory> role_context_factory;
std::unique_ptr<RowPolicyContextFactory> row_policy_context_factory;
2020-02-12 03:03:33 +00:00
std::unique_ptr<QuotaContextFactory> quota_context_factory;
};
}