2020-05-27 21:06:33 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Access/LDAPParams.h>
|
2020-09-15 09:55:57 +00:00
|
|
|
#include <common/types.h>
|
2020-05-27 21:06:33 +00:00
|
|
|
|
2020-12-24 21:49:19 +00:00
|
|
|
#include <chrono>
|
2020-05-27 21:06:33 +00:00
|
|
|
#include <map>
|
|
|
|
#include <mutex>
|
2020-12-24 21:49:19 +00:00
|
|
|
#include <unordered_map>
|
2020-05-27 21:06:33 +00:00
|
|
|
|
|
|
|
|
2020-05-29 12:14:42 +00:00
|
|
|
namespace Poco
|
|
|
|
{
|
2020-05-29 07:47:01 +00:00
|
|
|
class Logger;
|
2020-05-29 12:14:42 +00:00
|
|
|
|
2020-05-29 07:47:01 +00:00
|
|
|
namespace Util
|
|
|
|
{
|
|
|
|
class AbstractConfiguration;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-27 21:06:33 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class ExternalAuthenticators
|
|
|
|
{
|
|
|
|
public:
|
2020-07-11 17:06:01 +00:00
|
|
|
void reset();
|
2020-07-23 17:55:24 +00:00
|
|
|
void setConfiguration(const Poco::Util::AbstractConfiguration & config, Poco::Logger * log);
|
2020-12-24 21:49:19 +00:00
|
|
|
bool checkLDAPCredentials(const String & server, const String & user_name, const String & password) const;
|
2020-06-02 09:37:02 +00:00
|
|
|
|
2020-12-24 21:49:19 +00:00
|
|
|
private:
|
|
|
|
struct LDAPCacheEntry
|
|
|
|
{
|
|
|
|
std::size_t last_successful_password_hash = 0;
|
|
|
|
std::chrono::steady_clock::time_point last_successful_password_check_timestamp;
|
|
|
|
};
|
|
|
|
|
|
|
|
using LDAPServerCache = std::unordered_map<String, LDAPCacheEntry>; // user name -> cache entry
|
|
|
|
using LDAPServerCaches = std::map<String, LDAPServerCache>; // server name -> cache
|
|
|
|
using LDAPServersParams = std::map<String, LDAPServerParams>; // server name -> params
|
2020-05-27 21:06:33 +00:00
|
|
|
|
|
|
|
private:
|
2020-07-11 17:06:01 +00:00
|
|
|
mutable std::recursive_mutex mutex;
|
2020-12-24 21:49:19 +00:00
|
|
|
LDAPServersParams ldap_server_params;
|
|
|
|
mutable LDAPServerCaches ldap_server_caches;
|
2020-05-27 21:06:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|