]>
Commit | Line | Data |
---|---|---|
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 | 3 | |
9f95a23c | 4 | #pragma once |
7c673cae FG |
5 | #define TIME_BUF_SIZE 128 |
6 | ||
7 | #include <boost/optional.hpp> | |
8 | #include <boost/utility/typed_in_place_factory.hpp> | |
9 | ||
10 | #include "rgw_op.h" | |
11 | #include "rgw_rest.h" | |
12 | #include "rgw_swift_auth.h" | |
31f18b77 | 13 | #include "rgw_http_errors.h" |
7c673cae FG |
14 | |
15 | #include <boost/utility/string_ref.hpp> | |
16 | ||
17 | class RGWGetObj_ObjStore_SWIFT : public RGWGetObj_ObjStore { | |
18 | int custom_http_ret = 0; | |
19 | public: | |
20 | RGWGetObj_ObjStore_SWIFT() {} | |
21 | ~RGWGetObj_ObjStore_SWIFT() override {} | |
22 | ||
23 | int verify_permission() override; | |
24 | int get_params() override; | |
25 | int send_response_data_error() override; | |
26 | int send_response_data(bufferlist& bl, off_t ofs, off_t len) override; | |
27 | ||
28 | void set_custom_http_response(const int http_ret) { | |
29 | custom_http_ret = http_ret; | |
30 | } | |
31 | ||
32 | bool need_object_expiration() override { | |
33 | return true; | |
34 | } | |
35 | }; | |
36 | ||
37 | class RGWListBuckets_ObjStore_SWIFT : public RGWListBuckets_ObjStore { | |
38 | bool need_stats; | |
3efd9988 | 39 | bool wants_reversed; |
7c673cae | 40 | std::string prefix; |
9f95a23c | 41 | std::vector<rgw::sal::RGWBucketList> reverse_buffer; |
7c673cae FG |
42 | |
43 | uint64_t get_default_max() const override { | |
44 | return 0; | |
45 | } | |
3efd9988 | 46 | |
7c673cae | 47 | public: |
3efd9988 FG |
48 | RGWListBuckets_ObjStore_SWIFT() |
49 | : need_stats(true), | |
50 | wants_reversed(false) { | |
51 | } | |
7c673cae FG |
52 | ~RGWListBuckets_ObjStore_SWIFT() override {} |
53 | ||
54 | int get_params() override; | |
9f95a23c | 55 | void handle_listing_chunk(rgw::sal::RGWBucketList&& buckets) override; |
7c673cae | 56 | void send_response_begin(bool has_buckets) override; |
9f95a23c TL |
57 | void send_response_data(rgw::sal::RGWBucketList& buckets) override; |
58 | void send_response_data_reversed(rgw::sal::RGWBucketList& buckets); | |
59 | void dump_bucket_entry(const rgw::sal::RGWBucket& obj); | |
7c673cae FG |
60 | void send_response_end() override; |
61 | ||
62 | bool should_get_stats() override { return need_stats; } | |
63 | bool supports_account_metadata() override { return true; } | |
64 | }; | |
65 | ||
66 | class RGWListBucket_ObjStore_SWIFT : public RGWListBucket_ObjStore { | |
67 | string path; | |
68 | public: | |
69 | RGWListBucket_ObjStore_SWIFT() { | |
70 | default_max = 10000; | |
71 | } | |
72 | ~RGWListBucket_ObjStore_SWIFT() override {} | |
73 | ||
74 | int get_params() override; | |
75 | void send_response() override; | |
76 | bool need_container_stats() override { return true; } | |
77 | }; | |
78 | ||
79 | class RGWStatAccount_ObjStore_SWIFT : public RGWStatAccount_ObjStore { | |
80 | map<string, bufferlist> attrs; | |
81 | public: | |
82 | RGWStatAccount_ObjStore_SWIFT() { | |
83 | } | |
84 | ~RGWStatAccount_ObjStore_SWIFT() override {} | |
85 | ||
86 | void execute() override; | |
87 | void send_response() override; | |
88 | }; | |
89 | ||
90 | class RGWStatBucket_ObjStore_SWIFT : public RGWStatBucket_ObjStore { | |
91 | public: | |
92 | RGWStatBucket_ObjStore_SWIFT() {} | |
93 | ~RGWStatBucket_ObjStore_SWIFT() override {} | |
94 | ||
95 | void send_response() override; | |
96 | }; | |
97 | ||
98 | class RGWCreateBucket_ObjStore_SWIFT : public RGWCreateBucket_ObjStore { | |
99 | protected: | |
100 | bool need_metadata_upload() const override { return true; } | |
101 | public: | |
102 | RGWCreateBucket_ObjStore_SWIFT() {} | |
103 | ~RGWCreateBucket_ObjStore_SWIFT() override {} | |
104 | ||
105 | int get_params() override; | |
106 | void send_response() override; | |
107 | }; | |
108 | ||
109 | class RGWDeleteBucket_ObjStore_SWIFT : public RGWDeleteBucket_ObjStore { | |
110 | public: | |
111 | RGWDeleteBucket_ObjStore_SWIFT() {} | |
112 | ~RGWDeleteBucket_ObjStore_SWIFT() override {} | |
113 | ||
114 | void send_response() override; | |
115 | }; | |
116 | ||
117 | class RGWPutObj_ObjStore_SWIFT : public RGWPutObj_ObjStore { | |
118 | string lo_etag; | |
119 | public: | |
120 | RGWPutObj_ObjStore_SWIFT() {} | |
121 | ~RGWPutObj_ObjStore_SWIFT() override {} | |
122 | ||
11fdf7f2 TL |
123 | int update_slo_segment_size(rgw_slo_entry& entry); |
124 | ||
7c673cae FG |
125 | int verify_permission() override; |
126 | int get_params() override; | |
127 | void send_response() override; | |
128 | }; | |
129 | ||
130 | class RGWPutMetadataAccount_ObjStore_SWIFT : public RGWPutMetadataAccount_ObjStore { | |
131 | public: | |
132 | RGWPutMetadataAccount_ObjStore_SWIFT() {} | |
133 | ~RGWPutMetadataAccount_ObjStore_SWIFT() override {} | |
134 | ||
135 | int get_params() override; | |
136 | void send_response() override; | |
137 | }; | |
138 | ||
139 | class RGWPutMetadataBucket_ObjStore_SWIFT : public RGWPutMetadataBucket_ObjStore { | |
140 | public: | |
141 | RGWPutMetadataBucket_ObjStore_SWIFT() {} | |
142 | ~RGWPutMetadataBucket_ObjStore_SWIFT() override {} | |
143 | ||
144 | int get_params() override; | |
145 | void send_response() override; | |
146 | }; | |
147 | ||
148 | class RGWPutMetadataObject_ObjStore_SWIFT : public RGWPutMetadataObject_ObjStore { | |
149 | public: | |
150 | RGWPutMetadataObject_ObjStore_SWIFT() {} | |
151 | ~RGWPutMetadataObject_ObjStore_SWIFT() override {} | |
152 | ||
153 | int get_params() override; | |
154 | void send_response() override; | |
155 | bool need_object_expiration() override { return true; } | |
156 | }; | |
157 | ||
158 | class RGWDeleteObj_ObjStore_SWIFT : public RGWDeleteObj_ObjStore { | |
159 | public: | |
160 | RGWDeleteObj_ObjStore_SWIFT() {} | |
161 | ~RGWDeleteObj_ObjStore_SWIFT() override {} | |
162 | ||
163 | int verify_permission() override; | |
164 | int get_params() override; | |
165 | bool need_object_expiration() override { return true; } | |
166 | void send_response() override; | |
167 | }; | |
168 | ||
169 | class RGWCopyObj_ObjStore_SWIFT : public RGWCopyObj_ObjStore { | |
170 | bool sent_header; | |
171 | protected: | |
172 | void dump_copy_info(); | |
173 | public: | |
174 | RGWCopyObj_ObjStore_SWIFT() : sent_header(false) {} | |
175 | ~RGWCopyObj_ObjStore_SWIFT() override {} | |
176 | ||
177 | int init_dest_policy() override; | |
178 | int get_params() override; | |
179 | void send_response() override; | |
180 | void send_partial_response(off_t ofs) override; | |
181 | }; | |
182 | ||
183 | class RGWGetACLs_ObjStore_SWIFT : public RGWGetACLs_ObjStore { | |
184 | public: | |
185 | RGWGetACLs_ObjStore_SWIFT() {} | |
186 | ~RGWGetACLs_ObjStore_SWIFT() override {} | |
187 | ||
188 | void send_response() override {} | |
189 | }; | |
190 | ||
191 | class RGWPutACLs_ObjStore_SWIFT : public RGWPutACLs_ObjStore { | |
192 | public: | |
193 | RGWPutACLs_ObjStore_SWIFT() : RGWPutACLs_ObjStore() {} | |
194 | ~RGWPutACLs_ObjStore_SWIFT() override {} | |
195 | ||
196 | void send_response() override {} | |
197 | }; | |
198 | ||
199 | class RGWOptionsCORS_ObjStore_SWIFT : public RGWOptionsCORS_ObjStore { | |
200 | public: | |
201 | RGWOptionsCORS_ObjStore_SWIFT() {} | |
202 | ~RGWOptionsCORS_ObjStore_SWIFT() override {} | |
203 | ||
204 | void send_response() override; | |
205 | }; | |
206 | ||
207 | class RGWBulkDelete_ObjStore_SWIFT : public RGWBulkDelete_ObjStore { | |
208 | public: | |
209 | RGWBulkDelete_ObjStore_SWIFT() {} | |
210 | ~RGWBulkDelete_ObjStore_SWIFT() override {} | |
211 | ||
212 | int get_data(std::list<RGWBulkDelete::acct_path_t>& items, | |
213 | bool * is_truncated) override; | |
214 | void send_response() override; | |
215 | }; | |
216 | ||
217 | class RGWBulkUploadOp_ObjStore_SWIFT : public RGWBulkUploadOp_ObjStore { | |
218 | size_t conlen; | |
219 | size_t curpos; | |
220 | ||
221 | public: | |
222 | RGWBulkUploadOp_ObjStore_SWIFT() | |
223 | : conlen(0), | |
224 | curpos(0) { | |
225 | } | |
226 | ~RGWBulkUploadOp_ObjStore_SWIFT() = default; | |
227 | ||
228 | std::unique_ptr<StreamGetter> create_stream() override; | |
229 | void send_response() override; | |
230 | }; | |
231 | ||
232 | class RGWInfo_ObjStore_SWIFT : public RGWInfo_ObjStore { | |
233 | protected: | |
234 | struct info | |
235 | { | |
236 | bool is_admin_info; | |
11fdf7f2 | 237 | function<void (Formatter&, const ConfigProxy&, RGWRados&)> list_data; |
7c673cae FG |
238 | }; |
239 | ||
240 | static const vector<pair<string, struct info>> swift_info; | |
241 | public: | |
242 | RGWInfo_ObjStore_SWIFT() {} | |
243 | ~RGWInfo_ObjStore_SWIFT() override {} | |
244 | ||
245 | void execute() override; | |
246 | void send_response() override; | |
11fdf7f2 TL |
247 | static void list_swift_data(Formatter& formatter, const ConfigProxy& config, RGWRados& store); |
248 | static void list_tempauth_data(Formatter& formatter, const ConfigProxy& config, RGWRados& store); | |
249 | static void list_tempurl_data(Formatter& formatter, const ConfigProxy& config, RGWRados& store); | |
250 | static void list_slo_data(Formatter& formatter, const ConfigProxy& config, RGWRados& store); | |
9f95a23c | 251 | static bool is_expired(const std::string& expires, const DoutPrefixProvider* dpp); |
7c673cae FG |
252 | }; |
253 | ||
254 | ||
255 | class RGWFormPost : public RGWPostObj_ObjStore { | |
256 | std::string get_current_filename() const override; | |
257 | std::string get_current_content_type() const override; | |
258 | std::size_t get_max_file_size() /*const*/; | |
259 | bool is_next_file_to_upload() override; | |
260 | bool is_integral(); | |
261 | bool is_non_expired(); | |
31f18b77 FG |
262 | void get_owner_info(const req_state* s, |
263 | RGWUserInfo& owner_info) const; | |
7c673cae FG |
264 | |
265 | parts_collection_t ctrl_parts; | |
266 | boost::optional<post_form_part> current_data_part; | |
267 | std::string prefix; | |
268 | bool stream_done = false; | |
269 | ||
270 | class SignatureHelper; | |
271 | public: | |
272 | RGWFormPost() = default; | |
273 | ~RGWFormPost() = default; | |
274 | ||
9f95a23c | 275 | void init(rgw::sal::RGWRadosStore* store, |
7c673cae FG |
276 | req_state* s, |
277 | RGWHandler* dialect_handler) override; | |
278 | ||
279 | int get_params() override; | |
280 | int get_data(ceph::bufferlist& bl, bool& again) override; | |
281 | void send_response() override; | |
282 | ||
283 | static bool is_formpost_req(req_state* const s); | |
284 | }; | |
285 | ||
286 | class RGWFormPost::SignatureHelper | |
287 | { | |
288 | private: | |
289 | static constexpr uint32_t output_size = | |
290 | CEPH_CRYPTO_HMACSHA1_DIGESTSIZE * 2 + 1; | |
291 | ||
292 | unsigned char dest[CEPH_CRYPTO_HMACSHA1_DIGESTSIZE]; // 20 | |
293 | char dest_str[output_size]; | |
294 | ||
295 | public: | |
296 | SignatureHelper() = default; | |
297 | ||
298 | const char* calc(const std::string& key, | |
299 | const boost::string_ref& path_info, | |
300 | const boost::string_ref& redirect, | |
301 | const boost::string_ref& max_file_size, | |
302 | const boost::string_ref& max_file_count, | |
303 | const boost::string_ref& expires) { | |
304 | using ceph::crypto::HMACSHA1; | |
305 | using UCHARPTR = const unsigned char*; | |
306 | ||
307 | HMACSHA1 hmac((UCHARPTR) key.data(), key.size()); | |
308 | ||
309 | hmac.Update((UCHARPTR) path_info.data(), path_info.size()); | |
310 | hmac.Update((UCHARPTR) "\n", 1); | |
311 | ||
312 | hmac.Update((UCHARPTR) redirect.data(), redirect.size()); | |
313 | hmac.Update((UCHARPTR) "\n", 1); | |
314 | ||
315 | hmac.Update((UCHARPTR) max_file_size.data(), max_file_size.size()); | |
316 | hmac.Update((UCHARPTR) "\n", 1); | |
317 | ||
318 | hmac.Update((UCHARPTR) max_file_count.data(), max_file_count.size()); | |
319 | hmac.Update((UCHARPTR) "\n", 1); | |
320 | ||
321 | hmac.Update((UCHARPTR) expires.data(), expires.size()); | |
322 | ||
323 | hmac.Final(dest); | |
324 | ||
325 | buf_to_hex((UCHARPTR) dest, sizeof(dest), dest_str); | |
326 | ||
327 | return dest_str; | |
328 | } | |
329 | ||
330 | const char* get_signature() const { | |
331 | return dest_str; | |
332 | } | |
333 | ||
334 | bool is_equal_to(const std::string& rhs) const { | |
335 | /* never allow out-of-range exception */ | |
336 | if (rhs.size() < (output_size - 1)) { | |
337 | return false; | |
338 | } | |
339 | return rhs.compare(0 /* pos */, output_size, dest_str) == 0; | |
340 | } | |
341 | ||
342 | }; /* RGWFormPost::SignatureHelper */ | |
343 | ||
344 | ||
345 | class RGWSwiftWebsiteHandler { | |
9f95a23c | 346 | rgw::sal::RGWRadosStore* const store; |
7c673cae FG |
347 | req_state* const s; |
348 | RGWHandler_REST* const handler; | |
349 | ||
350 | bool is_web_mode() const; | |
351 | bool can_be_website_req() const; | |
352 | bool is_web_dir() const; | |
9f95a23c | 353 | bool is_index_present(const std::string& index) const; |
7c673cae FG |
354 | |
355 | int serve_errordoc(int http_ret, std::string error_doc); | |
356 | ||
357 | RGWOp* get_ws_redirect_op(); | |
358 | RGWOp* get_ws_index_op(); | |
359 | RGWOp* get_ws_listing_op(); | |
360 | public: | |
9f95a23c | 361 | RGWSwiftWebsiteHandler(rgw::sal::RGWRadosStore* const store, |
7c673cae FG |
362 | req_state* const s, |
363 | RGWHandler_REST* const handler) | |
364 | : store(store), | |
365 | s(s), | |
366 | handler(handler) { | |
367 | } | |
368 | ||
369 | int error_handler(const int err_no, | |
370 | std::string* const error_content); | |
371 | int retarget_bucket(RGWOp* op, RGWOp** new_op); | |
372 | int retarget_object(RGWOp* op, RGWOp** new_op); | |
373 | }; | |
374 | ||
375 | ||
376 | class RGWHandler_REST_SWIFT : public RGWHandler_REST { | |
377 | friend class RGWRESTMgr_SWIFT; | |
378 | friend class RGWRESTMgr_SWIFT_Info; | |
379 | protected: | |
380 | const rgw::auth::Strategy& auth_strategy; | |
381 | ||
9f95a23c | 382 | virtual bool is_acl_op() const { |
7c673cae FG |
383 | return false; |
384 | } | |
385 | ||
386 | static int init_from_header(struct req_state* s, | |
387 | const std::string& frontend_prefix); | |
388 | public: | |
11fdf7f2 | 389 | explicit RGWHandler_REST_SWIFT(const rgw::auth::Strategy& auth_strategy) |
7c673cae FG |
390 | : auth_strategy(auth_strategy) { |
391 | } | |
392 | ~RGWHandler_REST_SWIFT() override = default; | |
393 | ||
3efd9988 | 394 | int validate_bucket_name(const string& bucket); |
7c673cae | 395 | |
9f95a23c | 396 | int init(rgw::sal::RGWRadosStore *store, struct req_state *s, rgw::io::BasicClient *cio) override; |
11fdf7f2 | 397 | int authorize(const DoutPrefixProvider *dpp) override; |
7c673cae FG |
398 | int postauth_init() override; |
399 | ||
400 | RGWAccessControlPolicy *alloc_policy() { return nullptr; /* return new RGWAccessControlPolicy_SWIFT; */ } | |
401 | void free_policy(RGWAccessControlPolicy *policy) { delete policy; } | |
402 | }; | |
403 | ||
404 | class RGWHandler_REST_Service_SWIFT : public RGWHandler_REST_SWIFT { | |
405 | protected: | |
406 | RGWOp *op_get() override; | |
407 | RGWOp *op_head() override; | |
408 | RGWOp *op_put() override; | |
409 | RGWOp *op_post() override; | |
410 | RGWOp *op_delete() override; | |
411 | public: | |
412 | using RGWHandler_REST_SWIFT::RGWHandler_REST_SWIFT; | |
413 | ~RGWHandler_REST_Service_SWIFT() override = default; | |
414 | }; | |
415 | ||
416 | class RGWHandler_REST_Bucket_SWIFT : public RGWHandler_REST_SWIFT { | |
417 | /* We need the boost::optional here only because of handler's late | |
418 | * initialization (see the init() method). */ | |
419 | boost::optional<RGWSwiftWebsiteHandler> website_handler; | |
420 | protected: | |
9f95a23c | 421 | bool is_obj_update_op() const override { |
7c673cae FG |
422 | return s->op == OP_POST; |
423 | } | |
424 | ||
425 | RGWOp *get_obj_op(bool get_data); | |
426 | RGWOp *op_get() override; | |
427 | RGWOp *op_head() override; | |
428 | RGWOp *op_put() override; | |
429 | RGWOp *op_delete() override; | |
430 | RGWOp *op_post() override; | |
431 | RGWOp *op_options() override; | |
432 | public: | |
433 | using RGWHandler_REST_SWIFT::RGWHandler_REST_SWIFT; | |
434 | ~RGWHandler_REST_Bucket_SWIFT() override = default; | |
435 | ||
436 | int error_handler(int err_no, std::string *error_content) override { | |
437 | return website_handler->error_handler(err_no, error_content); | |
438 | } | |
439 | ||
440 | int retarget(RGWOp* op, RGWOp** new_op) override { | |
441 | return website_handler->retarget_bucket(op, new_op); | |
442 | } | |
443 | ||
9f95a23c | 444 | int init(rgw::sal::RGWRadosStore* const store, |
7c673cae FG |
445 | struct req_state* const s, |
446 | rgw::io::BasicClient* const cio) override { | |
447 | website_handler = boost::in_place<RGWSwiftWebsiteHandler>(store, s, this); | |
448 | return RGWHandler_REST_SWIFT::init(store, s, cio); | |
449 | } | |
450 | }; | |
451 | ||
452 | class RGWHandler_REST_Obj_SWIFT : public RGWHandler_REST_SWIFT { | |
453 | /* We need the boost::optional here only because of handler's late | |
454 | * initialization (see the init() method). */ | |
455 | boost::optional<RGWSwiftWebsiteHandler> website_handler; | |
456 | protected: | |
9f95a23c | 457 | bool is_obj_update_op() const override { |
7c673cae FG |
458 | return s->op == OP_POST; |
459 | } | |
460 | ||
461 | RGWOp *get_obj_op(bool get_data); | |
462 | RGWOp *op_get() override; | |
463 | RGWOp *op_head() override; | |
464 | RGWOp *op_put() override; | |
465 | RGWOp *op_delete() override; | |
466 | RGWOp *op_post() override; | |
467 | RGWOp *op_copy() override; | |
468 | RGWOp *op_options() override; | |
469 | ||
470 | public: | |
471 | using RGWHandler_REST_SWIFT::RGWHandler_REST_SWIFT; | |
472 | ~RGWHandler_REST_Obj_SWIFT() override = default; | |
473 | ||
474 | int error_handler(int err_no, std::string *error_content) override { | |
475 | return website_handler->error_handler(err_no, error_content); | |
476 | } | |
477 | ||
478 | int retarget(RGWOp* op, RGWOp** new_op) override { | |
479 | return website_handler->retarget_object(op, new_op); | |
480 | } | |
481 | ||
9f95a23c | 482 | int init(rgw::sal::RGWRadosStore* const store, |
7c673cae FG |
483 | struct req_state* const s, |
484 | rgw::io::BasicClient* const cio) override { | |
485 | website_handler = boost::in_place<RGWSwiftWebsiteHandler>(store, s, this); | |
486 | return RGWHandler_REST_SWIFT::init(store, s, cio); | |
487 | } | |
488 | }; | |
489 | ||
490 | class RGWRESTMgr_SWIFT : public RGWRESTMgr { | |
491 | protected: | |
492 | RGWRESTMgr* get_resource_mgr_as_default(struct req_state* const s, | |
493 | const std::string& uri, | |
494 | std::string* const out_uri) override { | |
495 | return this->get_resource_mgr(s, uri, out_uri); | |
496 | } | |
497 | ||
498 | public: | |
499 | RGWRESTMgr_SWIFT() = default; | |
500 | ~RGWRESTMgr_SWIFT() override = default; | |
501 | ||
502 | RGWHandler_REST *get_handler(struct req_state *s, | |
503 | const rgw::auth::StrategyRegistry& auth_registry, | |
504 | const std::string& frontend_prefix) override; | |
505 | }; | |
506 | ||
507 | ||
508 | class RGWGetCrossDomainPolicy_ObjStore_SWIFT | |
509 | : public RGWGetCrossDomainPolicy_ObjStore { | |
510 | public: | |
511 | RGWGetCrossDomainPolicy_ObjStore_SWIFT() = default; | |
512 | ~RGWGetCrossDomainPolicy_ObjStore_SWIFT() override = default; | |
513 | ||
514 | void send_response() override; | |
515 | }; | |
516 | ||
517 | class RGWGetHealthCheck_ObjStore_SWIFT | |
518 | : public RGWGetHealthCheck_ObjStore { | |
519 | public: | |
520 | RGWGetHealthCheck_ObjStore_SWIFT() = default; | |
521 | ~RGWGetHealthCheck_ObjStore_SWIFT() override = default; | |
522 | ||
523 | void send_response() override; | |
524 | }; | |
525 | ||
526 | class RGWHandler_SWIFT_CrossDomain : public RGWHandler_REST { | |
527 | public: | |
528 | RGWHandler_SWIFT_CrossDomain() = default; | |
529 | ~RGWHandler_SWIFT_CrossDomain() override = default; | |
530 | ||
531 | RGWOp *op_get() override { | |
532 | return new RGWGetCrossDomainPolicy_ObjStore_SWIFT(); | |
533 | } | |
534 | ||
9f95a23c | 535 | int init(rgw::sal::RGWRadosStore* const store, |
7c673cae FG |
536 | struct req_state* const state, |
537 | rgw::io::BasicClient* const cio) override { | |
538 | state->dialect = "swift"; | |
539 | state->formatter = new JSONFormatter; | |
540 | state->format = RGW_FORMAT_JSON; | |
541 | ||
542 | return RGWHandler::init(store, state, cio); | |
543 | } | |
544 | ||
11fdf7f2 | 545 | int authorize(const DoutPrefixProvider *dpp) override { |
7c673cae FG |
546 | return 0; |
547 | } | |
548 | ||
549 | int postauth_init() override { | |
550 | return 0; | |
551 | } | |
552 | ||
553 | int read_permissions(RGWOp *) override { | |
554 | return 0; | |
555 | } | |
556 | ||
557 | virtual RGWAccessControlPolicy *alloc_policy() { return nullptr; } | |
558 | virtual void free_policy(RGWAccessControlPolicy *policy) {} | |
559 | }; | |
560 | ||
561 | class RGWRESTMgr_SWIFT_CrossDomain : public RGWRESTMgr { | |
562 | protected: | |
563 | RGWRESTMgr *get_resource_mgr(struct req_state* const s, | |
564 | const std::string& uri, | |
565 | std::string* const out_uri) override { | |
566 | return this; | |
567 | } | |
568 | ||
569 | public: | |
570 | RGWRESTMgr_SWIFT_CrossDomain() = default; | |
571 | ~RGWRESTMgr_SWIFT_CrossDomain() override = default; | |
572 | ||
573 | RGWHandler_REST* get_handler(struct req_state* const s, | |
574 | const rgw::auth::StrategyRegistry&, | |
575 | const std::string&) override { | |
576 | s->prot_flags |= RGW_REST_SWIFT; | |
577 | return new RGWHandler_SWIFT_CrossDomain; | |
578 | } | |
579 | }; | |
580 | ||
581 | ||
582 | class RGWHandler_SWIFT_HealthCheck : public RGWHandler_REST { | |
583 | public: | |
584 | RGWHandler_SWIFT_HealthCheck() = default; | |
585 | ~RGWHandler_SWIFT_HealthCheck() override = default; | |
586 | ||
587 | RGWOp *op_get() override { | |
588 | return new RGWGetHealthCheck_ObjStore_SWIFT(); | |
589 | } | |
590 | ||
9f95a23c | 591 | int init(rgw::sal::RGWRadosStore* const store, |
7c673cae FG |
592 | struct req_state* const state, |
593 | rgw::io::BasicClient* const cio) override { | |
594 | state->dialect = "swift"; | |
595 | state->formatter = new JSONFormatter; | |
596 | state->format = RGW_FORMAT_JSON; | |
597 | ||
598 | return RGWHandler::init(store, state, cio); | |
599 | } | |
600 | ||
11fdf7f2 | 601 | int authorize(const DoutPrefixProvider *dpp) override { |
7c673cae FG |
602 | return 0; |
603 | } | |
604 | ||
605 | int postauth_init() override { | |
606 | return 0; | |
607 | } | |
608 | ||
609 | int read_permissions(RGWOp *) override { | |
610 | return 0; | |
611 | } | |
612 | ||
613 | virtual RGWAccessControlPolicy *alloc_policy() { return nullptr; } | |
614 | virtual void free_policy(RGWAccessControlPolicy *policy) {} | |
615 | }; | |
616 | ||
617 | class RGWRESTMgr_SWIFT_HealthCheck : public RGWRESTMgr { | |
618 | protected: | |
619 | RGWRESTMgr *get_resource_mgr(struct req_state* const s, | |
620 | const std::string& uri, | |
621 | std::string* const out_uri) override { | |
622 | return this; | |
623 | } | |
624 | ||
625 | public: | |
626 | RGWRESTMgr_SWIFT_HealthCheck() = default; | |
627 | ~RGWRESTMgr_SWIFT_HealthCheck() override = default; | |
628 | ||
629 | RGWHandler_REST* get_handler(struct req_state* const s, | |
630 | const rgw::auth::StrategyRegistry&, | |
631 | const std::string&) override { | |
632 | s->prot_flags |= RGW_REST_SWIFT; | |
633 | return new RGWHandler_SWIFT_HealthCheck; | |
634 | } | |
635 | }; | |
636 | ||
637 | ||
638 | class RGWHandler_REST_SWIFT_Info : public RGWHandler_REST_SWIFT { | |
639 | public: | |
640 | using RGWHandler_REST_SWIFT::RGWHandler_REST_SWIFT; | |
641 | ~RGWHandler_REST_SWIFT_Info() override = default; | |
642 | ||
643 | RGWOp *op_get() override { | |
644 | return new RGWInfo_ObjStore_SWIFT(); | |
645 | } | |
646 | ||
9f95a23c | 647 | int init(rgw::sal::RGWRadosStore* const store, |
7c673cae FG |
648 | struct req_state* const state, |
649 | rgw::io::BasicClient* const cio) override { | |
650 | state->dialect = "swift"; | |
651 | state->formatter = new JSONFormatter; | |
652 | state->format = RGW_FORMAT_JSON; | |
653 | ||
654 | return RGWHandler::init(store, state, cio); | |
655 | } | |
656 | ||
11fdf7f2 | 657 | int authorize(const DoutPrefixProvider *dpp) override { |
7c673cae FG |
658 | return 0; |
659 | } | |
660 | ||
661 | int postauth_init() override { | |
662 | return 0; | |
663 | } | |
664 | ||
665 | int read_permissions(RGWOp *) override { | |
666 | return 0; | |
667 | } | |
668 | }; | |
669 | ||
670 | class RGWRESTMgr_SWIFT_Info : public RGWRESTMgr { | |
671 | public: | |
672 | RGWRESTMgr_SWIFT_Info() = default; | |
673 | ~RGWRESTMgr_SWIFT_Info() override = default; | |
674 | ||
675 | RGWHandler_REST *get_handler(struct req_state* s, | |
676 | const rgw::auth::StrategyRegistry& auth_registry, | |
677 | const std::string& frontend_prefix) override; | |
678 | }; |