ClickHouse/src/Access/ExternalAuthenticators.h

53 lines
1.3 KiB
C++
Raw Normal View History

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
#include <chrono>
2020-05-27 21:06:33 +00:00
#include <map>
#include <mutex>
#include <unordered_map>
2020-05-27 21:06:33 +00:00
namespace Poco
{
class Logger;
namespace Util
{
class AbstractConfiguration;
}
}
2020-05-27 21:06:33 +00:00
namespace DB
{
class ExternalAuthenticators
{
public:
void reset();
void setConfiguration(const Poco::Util::AbstractConfiguration & config, Poco::Logger * log);
bool checkLDAPCredentials(const String & server, const String & user_name, const String & password,
const LDAPSearchParamsList * search_params = nullptr, LDAPSearchResultsList * search_results = nullptr) const;
private:
struct LDAPCacheEntry
{
2020-12-24 23:46:08 +00:00
std::size_t last_successful_params_hash = 0;
std::chrono::steady_clock::time_point last_successful_authentication_timestamp;
LDAPSearchResultsList last_successful_search_results;
};
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:
mutable std::recursive_mutex mutex;
LDAPServersParams ldap_server_params;
mutable LDAPServerCaches ldap_server_caches;
2020-05-27 21:06:33 +00:00
};
}