]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_auth_registry.h
import ceph 15.2.10
[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 ft=cpp
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 #include "rgw_rest_sts.h"
18
19 namespace rgw {
20 namespace auth {
21
22 /* A class aggregating the knowledge about all Strategies in RadosGW. It is
23 * responsible for handling the dynamic reconfiguration on e.g. realm update. */
24 class StrategyRegistry {
25 template <class AbstractorT,
26 bool AllowAnonAccessT = false>
27 using s3_strategy_t = \
28 rgw::auth::s3::AWSAuthStrategy<AbstractorT, AllowAnonAccessT>;
29
30 struct s3_main_strategy_t : public Strategy {
31 using s3_main_strategy_plain_t = \
32 s3_strategy_t<rgw::auth::s3::AWSGeneralAbstractor, true>;
33 using s3_main_strategy_boto2_t = \
34 s3_strategy_t<rgw::auth::s3::AWSGeneralBoto2Abstractor>;
35
36 s3_main_strategy_plain_t s3_main_strategy_plain;
37 s3_main_strategy_boto2_t s3_main_strategy_boto2;
38
39 s3_main_strategy_t(CephContext* const cct,
40 ImplicitTenants& implicit_tenant_context,
41 RGWCtl* const ctl)
42 : s3_main_strategy_plain(cct, implicit_tenant_context, ctl),
43 s3_main_strategy_boto2(cct, implicit_tenant_context, ctl) {
44 add_engine(Strategy::Control::SUFFICIENT, s3_main_strategy_plain);
45 add_engine(Strategy::Control::FALLBACK, s3_main_strategy_boto2);
46 }
47
48 const char* get_name() const noexcept override {
49 return "rgw::auth::StrategyRegistry::s3_main_strategy_t";
50 }
51 } s3_main_strategy;
52
53 using s3_post_strategy_t = \
54 s3_strategy_t<rgw::auth::s3::AWSBrowserUploadAbstractor>;
55 s3_post_strategy_t s3_post_strategy;
56
57 rgw::auth::swift::DefaultStrategy swift_strategy;
58
59 rgw::auth::sts::DefaultStrategy sts_strategy;
60
61 public:
62 StrategyRegistry(CephContext* const cct,
63 ImplicitTenants& implicit_tenant_context,
64 RGWCtl* const ctl)
65 : s3_main_strategy(cct, implicit_tenant_context, ctl),
66 s3_post_strategy(cct, implicit_tenant_context, ctl),
67 swift_strategy(cct, implicit_tenant_context, ctl),
68 sts_strategy(cct, implicit_tenant_context, ctl) {
69 }
70
71 const s3_main_strategy_t& get_s3_main() const {
72 return s3_main_strategy;
73 }
74
75 const s3_post_strategy_t& get_s3_post() const {
76 return s3_post_strategy;
77 }
78
79 const rgw::auth::swift::DefaultStrategy& get_swift() const {
80 return swift_strategy;
81 }
82
83 const rgw::auth::sts::DefaultStrategy& get_sts() const {
84 return sts_strategy;
85 }
86
87 static std::shared_ptr<StrategyRegistry>
88 create(CephContext* const cct,
89 ImplicitTenants& implicit_tenant_context,
90 RGWCtl* const ctl) {
91 return std::make_shared<StrategyRegistry>(cct, implicit_tenant_context, ctl);
92 }
93 };
94
95 } /* namespace auth */
96 } /* namespace rgw */
97
98 using rgw_auth_registry_t = rgw::auth::StrategyRegistry;
99 using rgw_auth_registry_ptr_t = std::shared_ptr<rgw_auth_registry_t>;
100
101 #endif /* CEPH_RGW_AUTH_REGISTRY_H */