]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_auth_registry.h
2b918f4fc3d208503809c9d091ffd439b03945d3
[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 using s3_strategy_t = rgw::auth::s3::AWSAuthStrategy<AbstractorT>;
26
27 struct s3_main_strategy_t : public Strategy {
28 using s3_main_strategy_plain_t = \
29 s3_strategy_t<rgw::auth::s3::AWSGeneralAbstractor>;
30 using s3_main_strategy_boto2_t = \
31 s3_strategy_t<rgw::auth::s3::AWSGeneralBoto2Abstractor>;
32
33 s3_main_strategy_plain_t s3_main_strategy_plain;
34 s3_main_strategy_boto2_t s3_main_strategy_boto2;
35
36 s3_main_strategy_t(CephContext* const cct, RGWRados* const store)
37 : s3_main_strategy_plain(cct, store),
38 s3_main_strategy_boto2(cct, store) {
39 add_engine(Strategy::Control::SUFFICIENT, s3_main_strategy_plain);
40 add_engine(Strategy::Control::FALLBACK, s3_main_strategy_boto2);
41 }
42
43 const char* get_name() const noexcept override {
44 return "rgw::auth::StrategyRegistry::s3_main_strategy_t";
45 }
46 } s3_main_strategy;
47
48 using s3_post_strategy_t = \
49 s3_strategy_t<rgw::auth::s3::AWSBrowserUploadAbstractor>;
50 s3_post_strategy_t s3_post_strategy;
51
52 rgw::auth::swift::DefaultStrategy swift_strategy;
53
54 public:
55 StrategyRegistry(CephContext* const cct,
56 RGWRados* const store)
57 : s3_main_strategy(cct, store),
58 s3_post_strategy(cct, store),
59 swift_strategy(cct, store) {
60 }
61
62 const s3_main_strategy_t& get_s3_main() const {
63 return s3_main_strategy;
64 }
65
66 const s3_post_strategy_t& get_s3_post() const {
67 return s3_post_strategy;
68 }
69
70 const rgw::auth::swift::DefaultStrategy& get_swift() const {
71 return swift_strategy;
72 }
73
74 static std::shared_ptr<StrategyRegistry>
75 create(CephContext* const cct,
76 RGWRados* const store) {
77 return std::make_shared<StrategyRegistry>(cct, store);
78 }
79 };
80
81 } /* namespace auth */
82 } /* namespace rgw */
83
84 using rgw_auth_registry_t = rgw::auth::StrategyRegistry;
85 using rgw_auth_registry_ptr_t = std::shared_ptr<rgw_auth_registry_t>;
86
87 #endif /* CEPH_RGW_AUTH_REGISTRY_H */