]>
Commit | Line | Data |
---|---|---|
f91f0fd5 TL |
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 | #ifndef CEPH_RGW_OIDC_PROVIDER_H | |
5 | #define CEPH_RGW_OIDC_PROVIDER_H | |
6 | ||
7 | #include <string> | |
8 | ||
9 | #include "common/ceph_context.h" | |
f67539c2 TL |
10 | #include "common/ceph_json.h" |
11 | ||
20effc67 | 12 | #include "rgw/rgw_sal.h" |
f91f0fd5 | 13 | |
20effc67 | 14 | namespace rgw { namespace sal { |
f91f0fd5 TL |
15 | |
16 | class RGWOIDCProvider | |
17 | { | |
20effc67 TL |
18 | public: |
19 | static const std::string oidc_url_oid_prefix; | |
20 | static const std::string oidc_arn_prefix; | |
f91f0fd5 TL |
21 | static constexpr int MAX_OIDC_NUM_CLIENT_IDS = 100; |
22 | static constexpr int MAX_OIDC_CLIENT_ID_LEN = 255; | |
23 | static constexpr int MAX_OIDC_NUM_THUMBPRINTS = 5; | |
24 | static constexpr int MAX_OIDC_THUMBPRINT_LEN = 40; | |
25 | static constexpr int MAX_OIDC_URL_LEN = 255; | |
26 | ||
20effc67 TL |
27 | protected: |
28 | std::string id; | |
29 | std::string provider_url; | |
30 | std::string arn; | |
31 | std::string creation_date; | |
32 | std::string tenant; | |
33 | std::vector<std::string> client_ids; | |
34 | std::vector<std::string> thumbprints; | |
35 | ||
36 | int get_tenant_url_from_arn(std::string& tenant, std::string& url); | |
37 | virtual int store_url(const DoutPrefixProvider *dpp, const std::string& url, bool exclusive, optional_yield y) = 0; | |
38 | virtual int read_url(const DoutPrefixProvider *dpp, const std::string& url, const std::string& tenant) = 0; | |
39 | bool validate_input(const DoutPrefixProvider *dpp); | |
f91f0fd5 TL |
40 | |
41 | public: | |
20effc67 TL |
42 | void set_arn(std::string _arn) { |
43 | arn = _arn; | |
44 | } | |
45 | void set_url(std::string _provider_url) { | |
46 | provider_url = _provider_url; | |
47 | } | |
48 | void set_tenant(std::string _tenant) { | |
49 | tenant = _tenant; | |
50 | } | |
51 | void set_client_ids(std::vector<std::string>& _client_ids) { | |
52 | client_ids = std::move(_client_ids); | |
53 | } | |
54 | void set_thumbprints(std::vector<std::string>& _thumbprints) { | |
55 | thumbprints = std::move(_thumbprints); | |
56 | } | |
57 | ||
58 | RGWOIDCProvider(std::string provider_url, | |
59 | std::string tenant, | |
60 | std::vector<std::string> client_ids, | |
61 | std::vector<std::string> thumbprints) | |
62 | : provider_url(std::move(provider_url)), | |
f91f0fd5 TL |
63 | tenant(std::move(tenant)), |
64 | client_ids(std::move(client_ids)), | |
65 | thumbprints(std::move(thumbprints)) { | |
66 | } | |
67 | ||
20effc67 TL |
68 | RGWOIDCProvider( std::string arn, |
69 | std::string tenant) | |
70 | : arn(std::move(arn)), | |
f91f0fd5 TL |
71 | tenant(std::move(tenant)) { |
72 | } | |
73 | ||
20effc67 TL |
74 | RGWOIDCProvider(std::string tenant) |
75 | : tenant(std::move(tenant)) {} | |
f91f0fd5 TL |
76 | |
77 | RGWOIDCProvider() {} | |
78 | ||
20effc67 | 79 | virtual ~RGWOIDCProvider() = default; |
f91f0fd5 TL |
80 | |
81 | void encode(bufferlist& bl) const { | |
82 | ENCODE_START(3, 1, bl); | |
83 | encode(id, bl); | |
84 | encode(provider_url, bl); | |
85 | encode(arn, bl); | |
86 | encode(creation_date, bl); | |
87 | encode(tenant, bl); | |
88 | encode(client_ids, bl); | |
89 | encode(thumbprints, bl); | |
90 | ENCODE_FINISH(bl); | |
91 | } | |
92 | ||
93 | void decode(bufferlist::const_iterator& bl) { | |
94 | DECODE_START(2, bl); | |
95 | decode(id, bl); | |
96 | decode(provider_url, bl); | |
97 | decode(arn, bl); | |
98 | decode(creation_date, bl); | |
99 | decode(tenant, bl); | |
100 | decode(client_ids, bl); | |
101 | decode(thumbprints, bl); | |
102 | DECODE_FINISH(bl); | |
103 | } | |
104 | ||
20effc67 TL |
105 | const std::string& get_provider_url() const { return provider_url; } |
106 | const std::string& get_arn() const { return arn; } | |
107 | const std::string& get_create_date() const { return creation_date; } | |
108 | const std::vector<std::string>& get_client_ids() const { return client_ids;} | |
109 | const std::vector<std::string>& get_thumbprints() const { return thumbprints; } | |
f91f0fd5 | 110 | |
b3b6e05e | 111 | int create(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y); |
20effc67 | 112 | virtual int delete_obj(const DoutPrefixProvider *dpp, optional_yield y) = 0; |
b3b6e05e | 113 | int get(const DoutPrefixProvider *dpp); |
f91f0fd5 TL |
114 | void dump(Formatter *f) const; |
115 | void dump_all(Formatter *f) const; | |
116 | void decode_json(JSONObj *obj); | |
117 | ||
20effc67 | 118 | static const std::string& get_url_oid_prefix(); |
f91f0fd5 TL |
119 | }; |
120 | WRITE_CLASS_ENCODER(RGWOIDCProvider) | |
20effc67 TL |
121 | |
122 | } } // namespace rgw::sal | |
f91f0fd5 TL |
123 | #endif /* CEPH_RGW_OIDC_PROVIDER_H */ |
124 |