return canonical_uri;
}
+static inline const string calc_v4_payload_hash(const string& payload)
+{
+ ceph::crypto::SHA256* sha256_hash = calc_hash_sha256_open_stream();
+ calc_hash_sha256_update_stream(sha256_hash, payload.c_str(), payload.length());
+ const auto payload_hash = calc_hash_sha256_close_stream(&sha256_hash);
+ return payload_hash;
+}
+
static inline const char* get_v4_exp_payload_hash(const req_info& info)
{
/* In AWSv4 the hash of real, transferred payload IS NOT necessary to form
throw -EPERM;
}
- /* Get the expected hash. */
- auto exp_payload_hash = rgw::auth::s3::get_v4_exp_payload_hash(s->info);
+ bool is_non_s3_op = false;
+ if (s->op_type == RGW_STS_GET_SESSION_TOKEN ||
+ s->op_type == RGW_STS_ASSUME_ROLE ||
+ s->op_type == RGW_STS_ASSUME_ROLE_WEB_IDENTITY) {
+ is_non_s3_op = true;
+ }
+
+ const char* exp_payload_hash = nullptr;
+ string payload_hash;
+ if (is_non_s3_op) {
+ //For non s3 ops, we need to calculate the payload hash
+ payload_hash = s->info.args.get("PayloadHash");
+ exp_payload_hash = payload_hash.c_str();
+ } else {
+ /* Get the expected hash. */
+ exp_payload_hash = rgw::auth::s3::get_v4_exp_payload_hash(s->info);
+ }
/* Craft canonical URI. Using std::move later so let it be non-const. */
auto canonical_uri = rgw::auth::s3::get_v4_canonical_uri(s->info);
* This means we have absolutely no business in spawning completer. Both
* aws4_auth_needs_complete and aws4_auth_streaming_mode are set to false
* by default. We don't need to change that. */
- if (is_v4_payload_unsigned(exp_payload_hash) || is_v4_payload_empty(s)) {
+ if (is_v4_payload_unsigned(exp_payload_hash) || is_v4_payload_empty(s) || is_non_s3_op) {
return {
access_key_id,
client_signature,
case RGW_OP_PUT_OBJ_TAGGING:
case RGW_OP_PUT_LC:
case RGW_OP_SET_REQUEST_PAYMENT:
- case RGW_STS_GET_SESSION_TOKEN:
- case RGW_STS_ASSUME_ROLE:
break;
default:
dout(10) << "ERROR: AWS4 completion for this operation NOT IMPLEMENTED" << dendl;
int ret = 0;
bufferlist data;
std::tie(ret, data) = rgw_rest_read_all_input(s, max_size, false);
+ string post_body = data.to_str();
if (data.length() > 0) {
- string post_body = data.to_str();
ldout(s->cct, 10) << "Content of POST: " << post_body << dendl;
if (post_body.find("Action") != string::npos) {
}
}
}
+ auto payload_hash = rgw::auth::s3::calc_v4_payload_hash(post_body);
+ s->info.args.append("PayloadHash", payload_hash);
}
RGWOp *RGWHandler_REST_STS::op_post()
void execute() override;
int verify_permission() override;
int get_params();
- const char* name() const override { return "get_keystone_session_token"; }
+ const char* name() const override { return "get_session_token"; }
RGWOpType get_type() override { return RGW_STS_GET_SESSION_TOKEN; }
};