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-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;
|
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();
|
|
|
|
|
2020-02-26 22:36:52 +00:00
|
|
|
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;
|
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
|
|
|
};
|
|
|
|
|
|
|
|
}
|