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