]> git.proxmox.com Git - ceph.git/blame - ceph/src/rgw/rgw_auth_s3.h
bump version to 15.2.11-pve1
[ceph.git] / ceph / src / rgw / rgw_auth_s3.h
CommitLineData
7c673cae 1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
9f95a23c 2// vim: ts=8 sw=2 smarttab ft=cpp
7c673cae
FG
3
4#ifndef CEPH_RGW_AUTH_S3_H
5#define CEPH_RGW_AUTH_S3_H
6
31f18b77
FG
7#include <array>
8#include <memory>
7c673cae
FG
9#include <string>
10#include <tuple>
11
31f18b77
FG
12#include <boost/algorithm/string.hpp>
13#include <boost/container/static_vector.hpp>
14#include <boost/utility/string_ref.hpp>
15#include <boost/utility/string_view.hpp>
16
17#include "common/sstring.hh"
7c673cae
FG
18#include "rgw_common.h"
19#include "rgw_rest_s3.h"
7c673cae
FG
20#include "rgw_auth.h"
21#include "rgw_auth_filters.h"
22#include "rgw_auth_keystone.h"
23
24
25namespace rgw {
26namespace auth {
27namespace s3 {
28
94b18763
FG
29static constexpr auto RGW_AUTH_GRACE = std::chrono::minutes{15};
30
31// returns true if the request time is within RGW_AUTH_GRACE of the current time
32bool is_time_skew_ok(time_t t);
33
11fdf7f2
TL
34class STSAuthStrategy : public rgw::auth::Strategy,
35 public rgw::auth::RemoteApplier::Factory,
36 public rgw::auth::LocalApplier::Factory,
37 public rgw::auth::RoleApplier::Factory {
38 typedef rgw::auth::IdentityApplier::aplptr_t aplptr_t;
9f95a23c
TL
39 RGWCtl* const ctl;
40 rgw::auth::ImplicitTenants& implicit_tenant_context;
11fdf7f2
TL
41
42 STSEngine sts_engine;
43
44 aplptr_t create_apl_remote(CephContext* const cct,
45 const req_state* const s,
46 rgw::auth::RemoteApplier::acl_strategy_t&& acl_alg,
47 const rgw::auth::RemoteApplier::AuthInfo &info
48 ) const override {
9f95a23c
TL
49 auto apl = rgw::auth::add_sysreq(cct, ctl, s,
50 rgw::auth::RemoteApplier(cct, ctl, std::move(acl_alg), info,
51 implicit_tenant_context,
52 rgw::auth::ImplicitTenants::IMPLICIT_TENANTS_S3));
11fdf7f2
TL
53 return aplptr_t(new decltype(apl)(std::move(apl)));
54 }
55
56 aplptr_t create_apl_local(CephContext* const cct,
57 const req_state* const s,
58 const RGWUserInfo& user_info,
59 const std::string& subuser,
60 const boost::optional<uint32_t>& perm_mask) const override {
9f95a23c 61 auto apl = rgw::auth::add_sysreq(cct, ctl, s,
11fdf7f2
TL
62 rgw::auth::LocalApplier(cct, user_info, subuser, perm_mask));
63 return aplptr_t(new decltype(apl)(std::move(apl)));
64 }
65
66 aplptr_t create_apl_role(CephContext* const cct,
67 const req_state* const s,
f91f0fd5 68 const rgw::auth::RoleApplier::Role& role,
11fdf7f2 69 const rgw_user& user_id,
f91f0fd5 70 const std::string& token_policy,
adb31ebb
TL
71 const std::string& role_session_name,
72 const std::vector<string>& token_claims) const override {
9f95a23c 73 auto apl = rgw::auth::add_sysreq(cct, ctl, s,
adb31ebb 74 rgw::auth::RoleApplier(cct, role, user_id, token_policy, role_session_name, token_claims));
11fdf7f2
TL
75 return aplptr_t(new decltype(apl)(std::move(apl)));
76 }
77
78public:
79 STSAuthStrategy(CephContext* const cct,
9f95a23c
TL
80 RGWCtl* const ctl,
81 rgw::auth::ImplicitTenants& implicit_tenant_context,
11fdf7f2 82 AWSEngine::VersionAbstractor* const ver_abstractor)
9f95a23c
TL
83 : ctl(ctl),
84 implicit_tenant_context(implicit_tenant_context),
85 sts_engine(cct, ctl, *ver_abstractor,
11fdf7f2
TL
86 static_cast<rgw::auth::LocalApplier::Factory*>(this),
87 static_cast<rgw::auth::RemoteApplier::Factory*>(this),
88 static_cast<rgw::auth::RoleApplier::Factory*>(this)) {
89 if (cct->_conf->rgw_s3_auth_use_sts) {
90 add_engine(Control::SUFFICIENT, sts_engine);
91 }
92 }
93
94 const char* get_name() const noexcept override {
95 return "rgw::auth::s3::STSAuthStrategy";
96 }
97};
98
7c673cae
FG
99class ExternalAuthStrategy : public rgw::auth::Strategy,
100 public rgw::auth::RemoteApplier::Factory {
101 typedef rgw::auth::IdentityApplier::aplptr_t aplptr_t;
9f95a23c
TL
102 RGWCtl* const ctl;
103 rgw::auth::ImplicitTenants& implicit_tenant_context;
7c673cae
FG
104
105 using keystone_config_t = rgw::keystone::CephCtxConfig;
106 using keystone_cache_t = rgw::keystone::TokenCache;
9f95a23c 107 using secret_cache_t = rgw::auth::keystone::SecretCache;
7c673cae
FG
108 using EC2Engine = rgw::auth::keystone::EC2Engine;
109
3efd9988 110 boost::optional <EC2Engine> keystone_engine;
7c673cae
FG
111 LDAPEngine ldap_engine;
112
113 aplptr_t create_apl_remote(CephContext* const cct,
114 const req_state* const s,
115 rgw::auth::RemoteApplier::acl_strategy_t&& acl_alg,
11fdf7f2 116 const rgw::auth::RemoteApplier::AuthInfo &info
7c673cae 117 ) const override {
9f95a23c
TL
118 auto apl = rgw::auth::add_sysreq(cct, ctl, s,
119 rgw::auth::RemoteApplier(cct, ctl, std::move(acl_alg), info,
120 implicit_tenant_context,
121 rgw::auth::ImplicitTenants::IMPLICIT_TENANTS_S3));
7c673cae
FG
122 /* TODO(rzarzynski): replace with static_ptr. */
123 return aplptr_t(new decltype(apl)(std::move(apl)));
124 }
125
126public:
127 ExternalAuthStrategy(CephContext* const cct,
9f95a23c
TL
128 RGWCtl* const ctl,
129 rgw::auth::ImplicitTenants& implicit_tenant_context,
31f18b77 130 AWSEngine::VersionAbstractor* const ver_abstractor)
9f95a23c
TL
131 : ctl(ctl),
132 implicit_tenant_context(implicit_tenant_context),
133 ldap_engine(cct, ctl, *ver_abstractor,
7c673cae
FG
134 static_cast<rgw::auth::RemoteApplier::Factory*>(this)) {
135
136 if (cct->_conf->rgw_s3_auth_use_keystone &&
137 ! cct->_conf->rgw_keystone_url.empty()) {
3efd9988
FG
138
139 keystone_engine.emplace(cct, ver_abstractor,
140 static_cast<rgw::auth::RemoteApplier::Factory*>(this),
141 keystone_config_t::get_instance(),
9f95a23c
TL
142 keystone_cache_t::get_instance<keystone_config_t>(),
143 secret_cache_t::get_instance());
3efd9988
FG
144 add_engine(Control::SUFFICIENT, *keystone_engine);
145
7c673cae
FG
146 }
147
a8e16298 148 if (ldap_engine.valid()) {
7c673cae
FG
149 add_engine(Control::SUFFICIENT, ldap_engine);
150 }
151 }
152
153 const char* get_name() const noexcept override {
154 return "rgw::auth::s3::AWSv2ExternalAuthStrategy";
155 }
156};
157
158
d2e6a577
FG
159template <class AbstractorT,
160 bool AllowAnonAccessT = false>
31f18b77
FG
161class AWSAuthStrategy : public rgw::auth::Strategy,
162 public rgw::auth::LocalApplier::Factory {
7c673cae
FG
163 typedef rgw::auth::IdentityApplier::aplptr_t aplptr_t;
164
31f18b77
FG
165 static_assert(std::is_base_of<rgw::auth::s3::AWSEngine::VersionAbstractor,
166 AbstractorT>::value,
167 "AbstractorT must be a subclass of rgw::auth::s3::VersionAbstractor");
7c673cae 168
9f95a23c 169 RGWCtl* const ctl;
31f18b77 170 AbstractorT ver_abstractor;
7c673cae 171
d2e6a577 172 S3AnonymousEngine anonymous_engine;
7c673cae 173 ExternalAuthStrategy external_engines;
11fdf7f2 174 STSAuthStrategy sts_engine;
31f18b77 175 LocalEngine local_engine;
7c673cae
FG
176
177 aplptr_t create_apl_local(CephContext* const cct,
178 const req_state* const s,
179 const RGWUserInfo& user_info,
11fdf7f2
TL
180 const std::string& subuser,
181 const boost::optional<uint32_t>& perm_mask) const override {
9f95a23c 182 auto apl = rgw::auth::add_sysreq(cct, ctl, s,
11fdf7f2 183 rgw::auth::LocalApplier(cct, user_info, subuser, perm_mask));
7c673cae
FG
184 /* TODO(rzarzynski): replace with static_ptr. */
185 return aplptr_t(new decltype(apl)(std::move(apl)));
186 }
187
188public:
1adf2230
AA
189 using engine_map_t = std::map <std::string, std::reference_wrapper<const Engine>>;
190 void add_engines(const std::vector <std::string>& auth_order,
191 engine_map_t eng_map)
192 {
193 auto ctrl_flag = Control::SUFFICIENT;
194 for (const auto &eng : auth_order) {
195 // fallback to the last engine, in case of multiple engines, since ctrl
196 // flag is sufficient for others, error from earlier engine is returned
197 if (&eng == &auth_order.back() && eng_map.size() > 1) {
198 ctrl_flag = Control::FALLBACK;
199 }
11fdf7f2
TL
200 if (const auto kv = eng_map.find(eng);
201 kv != eng_map.end()) {
1adf2230
AA
202 add_engine(ctrl_flag, kv->second);
203 }
204 }
205 }
206
11fdf7f2 207 auto parse_auth_order(CephContext* const cct)
1adf2230
AA
208 {
209 std::vector <std::string> result;
210
11fdf7f2
TL
211 const std::set <std::string_view> allowed_auth = { "sts", "external", "local" };
212 std::vector <std::string> default_order = { "sts", "external", "local" };
1adf2230
AA
213 // supplied strings may contain a space, so let's bypass that
214 boost::split(result, cct->_conf->rgw_s3_auth_order,
215 boost::is_any_of(", "), boost::token_compress_on);
216
217 if (std::any_of(result.begin(), result.end(),
11fdf7f2 218 [allowed_auth](std::string_view s)
1adf2230
AA
219 { return allowed_auth.find(s) == allowed_auth.end();})){
220 return default_order;
221 }
222 return result;
223 }
224
31f18b77 225 AWSAuthStrategy(CephContext* const cct,
9f95a23c
TL
226 rgw::auth::ImplicitTenants& implicit_tenant_context,
227 RGWCtl* const ctl)
228 : ctl(ctl),
31f18b77 229 ver_abstractor(cct),
d2e6a577
FG
230 anonymous_engine(cct,
231 static_cast<rgw::auth::LocalApplier::Factory*>(this)),
9f95a23c
TL
232 external_engines(cct, ctl, implicit_tenant_context, &ver_abstractor),
233 sts_engine(cct, ctl, implicit_tenant_context, &ver_abstractor),
234 local_engine(cct, ctl, ver_abstractor,
7c673cae 235 static_cast<rgw::auth::LocalApplier::Factory*>(this)) {
11fdf7f2 236 /* The anonymous auth. */
d2e6a577
FG
237 if (AllowAnonAccessT) {
238 add_engine(Control::SUFFICIENT, anonymous_engine);
239 }
7c673cae 240
1adf2230
AA
241 auto auth_order = parse_auth_order(cct);
242 engine_map_t engine_map;
11fdf7f2
TL
243
244 /* STS Auth*/
245 if (! sts_engine.is_empty()) {
246 engine_map.insert(std::make_pair("sts", std::cref(sts_engine)));
247 }
248
d2e6a577 249 /* The external auth. */
7c673cae 250 if (! external_engines.is_empty()) {
1adf2230 251 engine_map.insert(std::make_pair("external", std::cref(external_engines)));
7c673cae 252 }
d2e6a577 253 /* The local auth. */
7c673cae 254 if (cct->_conf->rgw_s3_auth_use_rados) {
1adf2230 255 engine_map.insert(std::make_pair("local", std::cref(local_engine)));
7c673cae 256 }
11fdf7f2 257
1adf2230 258 add_engines(auth_order, engine_map);
7c673cae
FG
259 }
260
261 const char* get_name() const noexcept override {
31f18b77 262 return "rgw::auth::s3::AWSAuthStrategy";
7c673cae
FG
263 }
264};
265
31f18b77
FG
266
267class AWSv4ComplMulti : public rgw::auth::Completer,
268 public rgw::io::DecoratedRestfulClient<rgw::io::RestfulClient*>,
269 public std::enable_shared_from_this<AWSv4ComplMulti> {
270 using io_base_t = rgw::io::DecoratedRestfulClient<rgw::io::RestfulClient*>;
11fdf7f2 271 using signing_key_t = sha256_digest_t;
31f18b77
FG
272
273 CephContext* const cct;
274
275 const boost::string_view date;
276 const boost::string_view credential_scope;
277 const signing_key_t signing_key;
278
279 class ChunkMeta {
280 size_t data_offset_in_stream = 0;
281 size_t data_length = 0;
282 std::string signature;
283
284 ChunkMeta(const size_t data_starts_in_stream,
285 const size_t data_length,
286 const boost::string_ref signature)
287 : data_offset_in_stream(data_starts_in_stream),
288 data_length(data_length),
289 signature(signature.to_string()) {
290 }
291
11fdf7f2 292 explicit ChunkMeta(const boost::string_view& signature)
31f18b77
FG
293 : signature(signature.to_string()) {
294 }
295
296 public:
297 static constexpr size_t SIG_SIZE = 64;
298
299 /* Let's suppose the data length fields can't exceed uint64_t. */
300 static constexpr size_t META_MAX_SIZE = \
301 sarrlen("\r\nffffffffffffffff;chunk-signature=") + SIG_SIZE + sarrlen("\r\n");
302
303 /* The metadata size of for the last, empty chunk. */
304 static constexpr size_t META_MIN_SIZE = \
305 sarrlen("0;chunk-signature=") + SIG_SIZE + sarrlen("\r\n");
306
307 /* Detect whether a given stream_pos fits in boundaries of a chunk. */
308 bool is_new_chunk_in_stream(size_t stream_pos) const;
309
310 /* Get the remaining data size. */
311 size_t get_data_size(size_t stream_pos) const;
312
313 const std::string& get_signature() const {
314 return signature;
315 }
316
317 /* Factory: create an object representing metadata of first, initial chunk
318 * in a stream. */
319 static ChunkMeta create_first(const boost::string_view& seed_signature) {
320 return ChunkMeta(seed_signature);
321 }
322
323 /* Factory: parse a block of META_MAX_SIZE bytes and creates an object
324 * representing non-first chunk in a stream. As the process is sequential
325 * and depends on the previous chunk, caller must pass it. */
326 static std::pair<ChunkMeta, size_t> create_next(CephContext* cct,
327 ChunkMeta&& prev,
328 const char* metabuf,
329 size_t metabuf_len);
330 } chunk_meta;
331
332 size_t stream_pos;
333 boost::container::static_vector<char, ChunkMeta::META_MAX_SIZE> parsing_buf;
334 ceph::crypto::SHA256* sha256_hash;
335 std::string prev_chunk_signature;
336
337 bool is_signature_mismatched();
338 std::string calc_chunk_signature(const std::string& payload_hash) const;
339
340public:
341 /* We need the constructor to be public because of the std::make_shared that
342 * is employed by the create() method. */
343 AWSv4ComplMulti(const req_state* const s,
344 boost::string_view date,
345 boost::string_view credential_scope,
346 boost::string_view seed_signature,
347 const signing_key_t& signing_key)
348 : io_base_t(nullptr),
349 cct(s->cct),
350 date(std::move(date)),
351 credential_scope(std::move(credential_scope)),
352 signing_key(signing_key),
353
354 /* The evolving state. */
355 chunk_meta(ChunkMeta::create_first(seed_signature)),
356 stream_pos(0),
357 sha256_hash(calc_hash_sha256_open_stream()),
358 prev_chunk_signature(std::move(seed_signature)) {
359 }
360
361 ~AWSv4ComplMulti() {
362 if (sha256_hash) {
363 calc_hash_sha256_close_stream(&sha256_hash);
364 }
365 }
366
367 /* rgw::io::DecoratedRestfulClient. */
368 size_t recv_body(char* buf, size_t max) override;
369
370 /* rgw::auth::Completer. */
11fdf7f2 371 void modify_request_state(const DoutPrefixProvider* dpp, req_state* s_rw) override;
31f18b77
FG
372 bool complete() override;
373
374 /* Factories. */
375 static cmplptr_t create(const req_state* s,
376 boost::string_view date,
377 boost::string_view credential_scope,
378 boost::string_view seed_signature,
379 const boost::optional<std::string>& secret_key);
380
381};
382
383class AWSv4ComplSingle : public rgw::auth::Completer,
384 public rgw::io::DecoratedRestfulClient<rgw::io::RestfulClient*>,
385 public std::enable_shared_from_this<AWSv4ComplSingle> {
386 using io_base_t = rgw::io::DecoratedRestfulClient<rgw::io::RestfulClient*>;
387
388 CephContext* const cct;
389 const char* const expected_request_payload_hash;
390 ceph::crypto::SHA256* sha256_hash = nullptr;
391
392public:
393 /* Defined in rgw_auth_s3.cc because of get_v4_exp_payload_hash(). We need
394 * the constructor to be public because of the std::make_shared employed by
395 * the create() method. */
11fdf7f2 396 explicit AWSv4ComplSingle(const req_state* const s);
31f18b77
FG
397
398 ~AWSv4ComplSingle() {
399 if (sha256_hash) {
400 calc_hash_sha256_close_stream(&sha256_hash);
401 }
402 }
403
404 /* rgw::io::DecoratedRestfulClient. */
405 size_t recv_body(char* buf, size_t max) override;
406
407 /* rgw::auth::Completer. */
11fdf7f2 408 void modify_request_state(const DoutPrefixProvider* dpp, req_state* s_rw) override;
31f18b77
FG
409 bool complete() override;
410
411 /* Factories. */
412 static cmplptr_t create(const req_state* s,
413 const boost::optional<std::string>&);
414
415};
416
7c673cae
FG
417} /* namespace s3 */
418} /* namespace auth */
419} /* namespace rgw */
420
421void rgw_create_s3_canonical_header(
422 const char *method,
423 const char *content_md5,
424 const char *content_type,
425 const char *date,
9f95a23c
TL
426 const meta_map_t& meta_map,
427 const meta_map_t& qs_map,
7c673cae
FG
428 const char *request_uri,
429 const std::map<std::string, std::string>& sub_resources,
430 std::string& dest_str);
431bool rgw_create_s3_canonical_header(const req_info& info,
432 utime_t *header_time, /* out */
433 std::string& dest, /* out */
434 bool qsr);
435static inline std::tuple<bool, std::string, utime_t>
436rgw_create_s3_canonical_header(const req_info& info, const bool qsr) {
437 std::string dest;
438 utime_t header_time;
439
440 const bool ok = rgw_create_s3_canonical_header(info, &header_time, dest, qsr);
441 return std::make_tuple(ok, dest, header_time);
442}
443
31f18b77
FG
444namespace rgw {
445namespace auth {
446namespace s3 {
447
448static constexpr char AWS4_HMAC_SHA256_STR[] = "AWS4-HMAC-SHA256";
224ce89b 449static constexpr char AWS4_HMAC_SHA256_PAYLOAD_STR[] = "AWS4-HMAC-SHA256-PAYLOAD";
31f18b77
FG
450
451static constexpr char AWS4_EMPTY_PAYLOAD_HASH[] = \
452 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
453
454static constexpr char AWS4_UNSIGNED_PAYLOAD_HASH[] = "UNSIGNED-PAYLOAD";
455
456static constexpr char AWS4_STREAMING_PAYLOAD_HASH[] = \
457 "STREAMING-AWS4-HMAC-SHA256-PAYLOAD";
458
a8e16298
TL
459int parse_v4_credentials(const req_info& info, /* in */
460 boost::string_view& access_key_id, /* out */
461 boost::string_view& credential_scope, /* out */
462 boost::string_view& signedheaders, /* out */
463 boost::string_view& signature, /* out */
464 boost::string_view& date, /* out */
11fdf7f2
TL
465 boost::string_view& session_token, /* out */
466 const bool using_qs); /* in */
467
468static inline bool char_needs_aws4_escaping(const char c, bool encode_slash)
469{
470 if ((c >= 'a' && c <= 'z') ||
471 (c >= 'A' && c <= 'Z') ||
472 (c >= '0' && c <= '9')) {
473 return false;
474 }
475
476 switch (c) {
477 case '-':
478 case '_':
479 case '.':
480 case '~':
481 return false;
482 }
483
484 if (c == '/' && !encode_slash)
485 return false;
486
487 return true;
488}
489
490static inline std::string aws4_uri_encode(const std::string& src, bool encode_slash)
491{
492 std::string result;
493
494 for (const std::string::value_type c : src) {
495 if (char_needs_aws4_escaping(c, encode_slash)) {
496 rgw_uri_escape_char(c, result);
497 } else {
498 result.push_back(c);
499 }
500 }
501
502 return result;
503}
504
505static inline std::string aws4_uri_recode(const boost::string_view& src, bool encode_slash)
506{
507 std::string decoded = url_decode(src);
508 return aws4_uri_encode(decoded, encode_slash);
509}
31f18b77
FG
510
511static inline std::string get_v4_canonical_uri(const req_info& info) {
512 /* The code should normalize according to RFC 3986 but S3 does NOT do path
513 * normalization that SigV4 typically does. This code follows the same
514 * approach that boto library. See auth.py:canonical_uri(...). */
515
11fdf7f2 516 std::string canonical_uri = aws4_uri_recode(info.request_uri_aws4, false);
31f18b77
FG
517
518 if (canonical_uri.empty()) {
519 canonical_uri = "/";
520 } else {
521 boost::replace_all(canonical_uri, "+", "%20");
522 }
523
524 return canonical_uri;
525}
526
11fdf7f2
TL
527static inline const string calc_v4_payload_hash(const string& payload)
528{
529 ceph::crypto::SHA256* sha256_hash = calc_hash_sha256_open_stream();
530 calc_hash_sha256_update_stream(sha256_hash, payload.c_str(), payload.length());
531 const auto payload_hash = calc_hash_sha256_close_stream(&sha256_hash);
532 return payload_hash;
533}
534
31f18b77
FG
535static inline const char* get_v4_exp_payload_hash(const req_info& info)
536{
11fdf7f2 537 /* In AWSv4 the hash of real, transferred payload IS NOT necessary to form
31f18b77
FG
538 * a Canonical Request, and thus verify a Signature. x-amz-content-sha256
539 * header lets get the information very early -- before seeing first byte
540 * of HTTP body. As a consequence, we can decouple Signature verification
541 * from payload's fingerprint check. */
542 const char *expected_request_payload_hash = \
543 info.env->get("HTTP_X_AMZ_CONTENT_SHA256");
544
545 if (!expected_request_payload_hash) {
546 /* An HTTP client MUST send x-amz-content-sha256. The single exception
547 * is the case of using the Query Parameters where "UNSIGNED-PAYLOAD"
548 * literals are used for crafting Canonical Request:
549 *
550 * You don't include a payload hash in the Canonical Request, because
551 * when you create a presigned URL, you don't know the payload content
552 * because the URL is used to upload an arbitrary payload. Instead, you
553 * use a constant string UNSIGNED-PAYLOAD. */
554 expected_request_payload_hash = AWS4_UNSIGNED_PAYLOAD_HASH;
555 }
556
557 return expected_request_payload_hash;
558}
559
560static inline bool is_v4_payload_unsigned(const char* const exp_payload_hash)
561{
562 return boost::equals(exp_payload_hash, AWS4_UNSIGNED_PAYLOAD_HASH);
563}
564
565static inline bool is_v4_payload_empty(const req_state* const s)
566{
567 /* from rfc2616 - 4.3 Message Body
568 *
569 * "The presence of a message-body in a request is signaled by the inclusion
570 * of a Content-Length or Transfer-Encoding header field in the request's
571 * message-headers." */
572 return s->content_length == 0 &&
573 s->info.env->get("HTTP_TRANSFER_ENCODING") == nullptr;
574}
575
576static inline bool is_v4_payload_streamed(const char* const exp_payload_hash)
577{
578 return boost::equals(exp_payload_hash, AWS4_STREAMING_PAYLOAD_HASH);
579}
580
581std::string get_v4_canonical_qs(const req_info& info, bool using_qs);
582
583boost::optional<std::string>
584get_v4_canonical_headers(const req_info& info,
585 const boost::string_view& signedheaders,
586 bool using_qs,
587 bool force_boto2_compat);
588
589extern sha256_digest_t
590get_v4_canon_req_hash(CephContext* cct,
591 const boost::string_view& http_verb,
592 const std::string& canonical_uri,
593 const std::string& canonical_qs,
594 const std::string& canonical_hdrs,
595 const boost::string_view& signed_hdrs,
596 const boost::string_view& request_payload_hash);
597
598AWSEngine::VersionAbstractor::string_to_sign_t
599get_v4_string_to_sign(CephContext* cct,
600 const boost::string_view& algorithm,
601 const boost::string_view& request_date,
602 const boost::string_view& credential_scope,
603 const sha256_digest_t& canonreq_hash);
604
605extern AWSEngine::VersionAbstractor::server_signature_t
606get_v4_signature(const boost::string_view& credential_scope,
607 CephContext* const cct,
608 const boost::string_view& secret_key,
609 const AWSEngine::VersionAbstractor::string_to_sign_t& string_to_sign);
610
611extern AWSEngine::VersionAbstractor::server_signature_t
612get_v2_signature(CephContext*,
613 const std::string& secret_key,
614 const AWSEngine::VersionAbstractor::string_to_sign_t& string_to_sign);
31f18b77
FG
615} /* namespace s3 */
616} /* namespace auth */
617} /* namespace rgw */
7c673cae
FG
618
619#endif