2020-06-01 17:16:09 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <memory>
|
|
|
|
#include <mutex>
|
2020-12-10 09:19:42 +00:00
|
|
|
#include <optional>
|
2020-09-15 09:55:57 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <common/types.h>
|
2020-06-01 17:16:09 +00:00
|
|
|
|
|
|
|
namespace Poco::Util
|
|
|
|
{
|
|
|
|
class AbstractConfiguration;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
struct HttpHeader
|
|
|
|
{
|
2021-03-04 15:56:55 +00:00
|
|
|
String name;
|
|
|
|
String value;
|
|
|
|
|
|
|
|
inline bool operator==(const HttpHeader & other) const { return name == other.name && value == other.value; }
|
2020-06-01 17:16:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
using HeaderCollection = std::vector<HttpHeader>;
|
|
|
|
|
|
|
|
struct S3AuthSettings
|
|
|
|
{
|
2021-03-04 15:56:55 +00:00
|
|
|
String access_key_id;
|
|
|
|
String secret_access_key;
|
|
|
|
String server_side_encryption_customer_key_base64;
|
2020-06-01 17:16:09 +00:00
|
|
|
|
2021-03-04 15:56:55 +00:00
|
|
|
HeaderCollection headers;
|
2020-12-10 09:19:42 +00:00
|
|
|
|
|
|
|
std::optional<bool> use_environment_credentials;
|
2021-03-30 00:32:26 +00:00
|
|
|
std::optional<bool> use_insecure_imds_request;
|
2021-03-04 15:56:55 +00:00
|
|
|
|
|
|
|
inline bool operator==(const S3AuthSettings & other) const
|
|
|
|
{
|
|
|
|
return access_key_id == other.access_key_id && secret_access_key == other.secret_access_key
|
|
|
|
&& server_side_encryption_customer_key_base64 == other.server_side_encryption_customer_key_base64 && headers == other.headers
|
2021-03-18 07:36:11 +00:00
|
|
|
&& use_environment_credentials == other.use_environment_credentials
|
2021-03-30 00:32:26 +00:00
|
|
|
&& use_insecure_imds_request == other.use_insecure_imds_request;
|
2021-03-04 15:56:55 +00:00
|
|
|
}
|
2020-06-01 17:16:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// Settings for the StorageS3.
|
|
|
|
class StorageS3Settings
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
StorageS3Settings() = default;
|
|
|
|
void loadFromConfig(const String & config_elem, const Poco::Util::AbstractConfiguration & config);
|
|
|
|
|
|
|
|
S3AuthSettings getSettings(const String & endpoint) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
mutable std::mutex mutex;
|
|
|
|
std::map<const String, const S3AuthSettings> settings;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|