2017-11-27 21:31:13 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Interpreters/ISecurityManager.h>
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2017-11-28 00:52:56 +00:00
|
|
|
/** Default implementation of security manager used by native server application.
|
|
|
|
* Manages fixed set of users listed in 'Users' configuration file.
|
|
|
|
*/
|
2017-11-27 21:31:13 +00:00
|
|
|
class SecurityManager : public ISecurityManager
|
|
|
|
{
|
|
|
|
private:
|
2017-11-30 14:53:12 +00:00
|
|
|
using Container = std::map<String, UserPtr>;
|
2017-11-27 21:31:13 +00:00
|
|
|
Container users;
|
|
|
|
|
|
|
|
public:
|
|
|
|
void loadFromConfig(Poco::Util::AbstractConfiguration & config) override;
|
|
|
|
|
2017-11-30 14:53:12 +00:00
|
|
|
UserPtr authorizeAndGetUser(
|
2017-11-27 21:31:13 +00:00
|
|
|
const String & user_name,
|
|
|
|
const String & password,
|
|
|
|
const Poco::Net::IPAddress & address) const override;
|
|
|
|
|
2017-11-30 14:53:12 +00:00
|
|
|
UserPtr getUser(const String & user_name) const override;
|
2017-11-27 21:31:13 +00:00
|
|
|
|
|
|
|
bool hasAccessToDatabase(const String & user_name, const String & database_name) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|