1#pragma once
2
3#include <map>
4#include <Interpreters/Users.h>
5
6namespace DB
7{
8
9/** Default implementation of users manager used by native server application.
10 * Manages fixed set of users listed in 'Users' configuration file.
11 */
12class UsersManager
13{
14public:
15 using UserPtr = std::shared_ptr<const User>;
16
17 void loadFromConfig(const Poco::Util::AbstractConfiguration & config);
18
19 UserPtr authorizeAndGetUser(
20 const String & user_name,
21 const String & password,
22 const Poco::Net::IPAddress & address) const;
23
24 UserPtr getUser(const String & user_name) const;
25
26 bool hasAccessToDatabase(const String & user_name, const String & database_name) const;
27 bool hasAccessToDictionary(const String & user_name, const String & dictionary_name) const;
28
29private:
30 using Container = std::map<String, UserPtr>;
31 Container users;
32};
33
34}
35