]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_auth_registry.h
update sources to 12.2.7
[ceph.git] / ceph / src / rgw / rgw_auth_registry.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4
5 #ifndef CEPH_RGW_AUTH_REGISTRY_H
6 #define CEPH_RGW_AUTH_REGISTRY_H
7
8 #include <functional>
9 #include <memory>
10 #include <ostream>
11 #include <type_traits>
12 #include <utility>
13
14 #include "rgw_auth.h"
15 #include "rgw_auth_s3.h"
16 #include "rgw_swift_auth.h"
17
18 namespace rgw {
19 namespace auth {
20
21 /* A class aggregating the knowledge about all Strategies in RadosGW. It is
22 * responsible for handling the dynamic reconfiguration on e.g. realm update. */
23 class StrategyRegistry {
24 template <class AbstractorT,
25 bool AllowAnonAccessT = false>
26 using s3_strategy_t = \
27 rgw::auth::s3::AWSAuthStrategy<AbstractorT, AllowAnonAccessT>;
28
29 struct s3_main_strategy_t : public Strategy {
30 using s3_main_strategy_plain_t = \
31 s3_strategy_t<rgw::auth::s3::AWSGeneralAbstractor, true>;
32 using s3_main_strategy_boto2_t = \
33 s3_strategy_t<rgw::auth::s3::AWSGeneralBoto2Abstractor, true>;
34
35 s3_main_strategy_plain_t s3_main_strategy_plain;
36 s3_main_strategy_boto2_t s3_main_strategy_boto2;
37
38 s3_main_strategy_t(CephContext* const cct,
39 ImplicitTenants& implicit_tenant_context,
40 RGWRados* const store)
41 : s3_main_strategy_plain(cct, implicit_tenant_context, store),
42 s3_main_strategy_boto2(cct, implicit_tenant_context, store) {
43 add_engine(Strategy::Control::SUFFICIENT, s3_main_strategy_plain);
44 add_engine(Strategy::Control::FALLBACK, s3_main_strategy_boto2);
45 }
46
47 const char* get_name() const noexcept override {
48 return "rgw::auth::StrategyRegistry::s3_main_strategy_t";
49 }
50 } s3_main_strategy;
51
52 using s3_post_strategy_t = \
53 s3_strategy_t<rgw::auth::s3::AWSBrowserUploadAbstractor>;
54 s3_post_strategy_t s3_post_strategy;
55
56 rgw::auth::swift::DefaultStrategy swift_strategy;
57
58 public:
59 StrategyRegistry(CephContext* const cct,
60 ImplicitTenants& implicit_tenant_context,
61 RGWRados* const store)
62 : s3_main_strategy(cct, implicit_tenant_context, store),
63 s3_post_strategy(cct, implicit_tenant_context, store),
64 swift_strategy(cct, implicit_tenant_context, store) {
65 }
66
67 const s3_main_strategy_t& get_s3_main() const {
68 return s3_main_strategy;
69 }
70
71 const s3_post_strategy_t& get_s3_post() const {
72 return s3_post_strategy;
73 }
74
75 const rgw::auth::swift::DefaultStrategy& get_swift() const {
76 return swift_strategy;
77 }
78
79 static std::shared_ptr<StrategyRegistry>
80 create(CephContext* const cct,
81 ImplicitTenants& implicit_tenant_context,
82 RGWRados* const store) {
83 return std::make_shared<StrategyRegistry>(cct, implicit_tenant_context, store);
84 }
85 };
86
87 } /* namespace auth */
88 } /* namespace rgw */
89
90 using rgw_auth_registry_t = rgw::auth::StrategyRegistry;
91 using rgw_auth_registry_ptr_t = std::shared_ptr<rgw_auth_registry_t>;
92
93 #endif /* CEPH_RGW_AUTH_REGISTRY_H */