diff options
author | Yehuda Sadeh <yehuda@redhat.com> | 2021-03-11 16:09:20 +0100 |
---|---|---|
committer | Yehuda Sadeh <yehuda@redhat.com> | 2021-03-11 16:12:51 +0100 |
commit | 0214b4a7afb8921e85517f4ad980f66c2957af3a (patch) | |
tree | 4a013e9958ad428bac6a2e830ba9681f4c014128 /src/rgw/rgw_op.h | |
parent | tests/rgw-multi: add meta checkpoint to test_bucket_creation_time (diff) | |
download | ceph-0214b4a7afb8921e85517f4ad980f66c2957af3a.tar.xz ceph-0214b4a7afb8921e85517f4ad980f66c2957af3a.zip |
rgw: handle aws4 completion when reading all op data
and add a few ops to the list of ops that complete aws4 signature.
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
Diffstat (limited to 'src/rgw/rgw_op.h')
-rw-r--r-- | src/rgw/rgw_op.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index 8df15c42e41..673ce92f691 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -124,6 +124,47 @@ void rgw_bucket_object_pre_exec(struct req_state *s); namespace dmc = rgw::dmclock; +std::tuple<int, bufferlist > rgw_rest_read_all_input(struct req_state *s, + const uint64_t max_len, + const bool allow_chunked=true); + +template <class T> +int rgw_rest_get_json_input(CephContext *cct, req_state *s, T& out, + uint64_t max_len, bool *empty) +{ + if (empty) + *empty = false; + + int rv = 0; + bufferlist data; + std::tie(rv, data) = rgw_rest_read_all_input(s, max_len); + if (rv < 0) { + return rv; + } + + if (!data.length()) { + if (empty) { + *empty = true; + } + + return -EINVAL; + } + + JSONParser parser; + + if (!parser.parse(data.c_str(), data.length())) { + return -EINVAL; + } + + try { + decode_json_obj(out, &parser); + } catch (JSONDecoder::err& e) { + return -EINVAL; + } + + return 0; +} + /** * Provide the base class for all ops. */ @@ -141,6 +182,30 @@ protected: virtual int init_quota(); + std::tuple<int, bufferlist> read_all_input(struct req_state *s, + const uint64_t max_len, + const bool allow_chunked=true) { + + int rv = 0; + bufferlist data; + std::tie(rv, data) = rgw_rest_read_all_input(s, max_len); + if (rv >= 0) { + do_aws4_auth_completion(); + } + + return std::make_tuple(rv, std::move(data)); + } + + template <class T> + int get_json_input(CephContext *cct, req_state *s, T& out, + uint64_t max_len, bool *empty) { + int r = rgw_rest_get_json_input(cct, s, out, max_len, empty); + if (r >= 0) { + do_aws4_auth_completion(); + } + return r; + } + public: RGWOp() : s(nullptr), |