Files
scylladb/utils/s3/client.hh
Pavel Emelyanov 98b9c205bb s3/client: Sign requests if configured
If the endpoint config specifies AWS key, secret and region, all the
S3 requests get signed. Signature should have all the x-amz-... headers
included and should contain at least three of them. This patch includes
x-ams-date, x-amz-content-sha256 and host headers into the signing list.
The content can be unsigned when sent over HTTPS, this is what this
patch does.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2023-05-03 20:23:37 +03:00

52 lines
1.3 KiB
C++

/*
* Copyright (C) 2022-present ScyllaDB
*/
/*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#include <seastar/core/file.hh>
#include <seastar/core/sstring.hh>
#include <seastar/core/shared_ptr.hh>
#include <seastar/http/client.hh>
#include "utils/s3/creds.hh"
using namespace seastar;
class memory_data_sink_buffers;
namespace s3 {
struct range {
uint64_t off;
size_t len;
};
class client : public enable_shared_from_this<client> {
class upload_sink;
class readable_file;
std::string _host;
endpoint_config_ptr _cfg;
http::experimental::client _http;
struct private_tag {};
void authorize(http::request&);
public:
explicit client(std::string host, endpoint_config_ptr cfg, private_tag);
static shared_ptr<client> make(std::string endpoint, endpoint_config_ptr cfg);
future<uint64_t> get_object_size(sstring object_name);
future<temporary_buffer<char>> get_object_contiguous(sstring object_name, std::optional<range> range = {});
future<> put_object(sstring object_name, temporary_buffer<char> buf);
future<> put_object(sstring object_name, ::memory_data_sink_buffers bufs);
future<> delete_object(sstring object_name);
file make_readable_file(sstring object_name);
data_sink make_upload_sink(sstring object_name);
future<> close();
};
} // s3 namespace