1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
5 #ifndef CEPH_RGW_AUTH_REGISTRY_H
6 #define CEPH_RGW_AUTH_REGISTRY_H
11 #include <type_traits>
15 #include "rgw_auth_s3.h"
16 #include "rgw_swift_auth.h"
17 #include "rgw_rest_sts.h"
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
>;
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
>;
36 s3_main_strategy_plain_t s3_main_strategy_plain
;
37 s3_main_strategy_boto2_t s3_main_strategy_boto2
;
39 s3_main_strategy_t(CephContext
* const cct
,
40 ImplicitTenants
& implicit_tenant_context
,
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
);
48 const char* get_name() const noexcept override
{
49 return "rgw::auth::StrategyRegistry::s3_main_strategy_t";
53 using s3_post_strategy_t
= \
54 s3_strategy_t
<rgw::auth::s3::AWSBrowserUploadAbstractor
>;
55 s3_post_strategy_t s3_post_strategy
;
57 rgw::auth::swift::DefaultStrategy swift_strategy
;
59 rgw::auth::sts::DefaultStrategy sts_strategy
;
62 StrategyRegistry(CephContext
* const cct
,
63 ImplicitTenants
& implicit_tenant_context
,
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
) {
71 const s3_main_strategy_t
& get_s3_main() const {
72 return s3_main_strategy
;
75 const s3_post_strategy_t
& get_s3_post() const {
76 return s3_post_strategy
;
79 const rgw::auth::swift::DefaultStrategy
& get_swift() const {
80 return swift_strategy
;
83 const rgw::auth::sts::DefaultStrategy
& get_sts() const {
87 static std::shared_ptr
<StrategyRegistry
>
88 create(CephContext
* const cct
,
89 ImplicitTenants
& implicit_tenant_context
,
91 return std::make_shared
<StrategyRegistry
>(cct
, implicit_tenant_context
, ctl
);
95 } /* namespace auth */
98 using rgw_auth_registry_t
= rgw::auth::StrategyRegistry
;
99 using rgw_auth_registry_ptr_t
= std::shared_ptr
<rgw_auth_registry_t
>;
101 #endif /* CEPH_RGW_AUTH_REGISTRY_H */