2017-11-27 21:31:13 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Interpreters/Users.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2019-03-29 20:31:06 +00:00
|
|
|
/** Duties of users manager:
|
2017-11-28 00:52:56 +00:00
|
|
|
* 1) Authenticate users
|
2017-11-28 01:08:21 +00:00
|
|
|
* 2) Provide user settings (profile, quota, ACLs)
|
2017-11-28 00:52:56 +00:00
|
|
|
* 3) Grant access to databases
|
|
|
|
*/
|
2019-03-29 20:31:06 +00:00
|
|
|
class IUsersManager
|
2017-11-27 21:31:13 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-11-30 14:53:12 +00:00
|
|
|
using UserPtr = std::shared_ptr<const User>;
|
|
|
|
|
2019-03-29 20:31:06 +00:00
|
|
|
virtual ~IUsersManager() = default;
|
|
|
|
|
2018-07-08 04:54:37 +00:00
|
|
|
virtual void loadFromConfig(const Poco::Util::AbstractConfiguration & config) = 0;
|
2017-11-27 21:31:13 +00:00
|
|
|
|
|
|
|
/// Find user and make authorize checks
|
2017-11-30 14:53:12 +00:00
|
|
|
virtual UserPtr authorizeAndGetUser(
|
2017-11-27 21:31:13 +00:00
|
|
|
const String & user_name,
|
|
|
|
const String & password,
|
|
|
|
const Poco::Net::IPAddress & address) const = 0;
|
|
|
|
|
|
|
|
/// Just find user
|
2017-11-30 14:53:12 +00:00
|
|
|
virtual UserPtr getUser(const String & user_name) const = 0;
|
2017-11-27 21:31:13 +00:00
|
|
|
|
|
|
|
/// Check if the user has access to the database.
|
|
|
|
virtual bool hasAccessToDatabase(const String & user_name, const String & database_name) const = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|