2019-11-09 15:33:07 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Access/MultipleAccessStorage.h>
|
|
|
|
#include <Poco/AutoPtr.h>
|
2019-11-04 19:17:27 +00:00
|
|
|
#include <memory>
|
2019-11-09 15:33:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace Poco
|
|
|
|
{
|
2019-11-04 19:17:27 +00:00
|
|
|
namespace Net
|
|
|
|
{
|
|
|
|
class IPAddress;
|
|
|
|
}
|
2019-11-09 15:33:07 +00:00
|
|
|
namespace Util
|
|
|
|
{
|
|
|
|
class AbstractConfiguration;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2020-02-12 23:59:49 +00:00
|
|
|
class AccessRightsContext;
|
|
|
|
using AccessRightsContextPtr = std::shared_ptr<const AccessRightsContext>;
|
2020-02-12 03:03:33 +00:00
|
|
|
class AccessRightsContextFactory;
|
2020-02-12 23:59:49 +00:00
|
|
|
class RowPolicyContext;
|
|
|
|
using RowPolicyContextPtr = std::shared_ptr<const RowPolicyContext>;
|
|
|
|
class RowPolicyContextFactory;
|
2019-11-04 19:17:27 +00:00
|
|
|
class QuotaContext;
|
2020-02-12 23:59:49 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
2019-11-09 15:33:07 +00:00
|
|
|
/// Manages access control entities.
|
|
|
|
class AccessControlManager : public MultipleAccessStorage
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AccessControlManager();
|
|
|
|
~AccessControlManager();
|
|
|
|
|
|
|
|
void loadFromConfig(const Poco::Util::AbstractConfiguration & users_config);
|
2019-11-04 19:17:27 +00:00
|
|
|
|
2020-02-12 03:03:33 +00:00
|
|
|
AccessRightsContextPtr getAccessRightsContext(
|
|
|
|
const UUID & user_id, const Settings & settings, const String & current_database, const ClientInfo & client_info) const;
|
2020-01-12 21:00:55 +00:00
|
|
|
|
2020-02-10 02:26:56 +00:00
|
|
|
RowPolicyContextPtr getRowPolicyContext(const UUID & user_id) const;
|
2019-11-04 19:17:27 +00:00
|
|
|
|
2020-02-12 03:03:33 +00:00
|
|
|
QuotaContextPtr getQuotaContext(
|
|
|
|
const UUID & user_id, const String & user_name, const Poco::Net::IPAddress & address, const String & custom_quota_key) const;
|
|
|
|
|
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;
|
2019-11-17 11:57:02 +00:00
|
|
|
std::unique_ptr<RowPolicyContextFactory> row_policy_context_factory;
|
2020-02-12 03:03:33 +00:00
|
|
|
std::unique_ptr<QuotaContextFactory> quota_context_factory;
|
2019-11-09 15:33:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|