]> git.proxmox.com Git - ceph.git/blame - ceph/src/rgw/rgw_oidc_provider.h
import ceph 15.2.10
[ceph.git] / ceph / src / rgw / rgw_oidc_provider.h
CommitLineData
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"
10
11class RGWCtl;
12
13class RGWOIDCProvider
14{
15 using string = std::string;
16 static const string oidc_url_oid_prefix;
17 static const string oidc_arn_prefix;
18 static constexpr int MAX_OIDC_NUM_CLIENT_IDS = 100;
19 static constexpr int MAX_OIDC_CLIENT_ID_LEN = 255;
20 static constexpr int MAX_OIDC_NUM_THUMBPRINTS = 5;
21 static constexpr int MAX_OIDC_THUMBPRINT_LEN = 40;
22 static constexpr int MAX_OIDC_URL_LEN = 255;
23
24 CephContext *cct;
25 RGWCtl *ctl;
26 string id;
27 string provider_url;
28 string arn;
29 string creation_date;
30 string tenant;
31 vector<string> client_ids;
32 vector<string> thumbprints;
33
34 int get_tenant_url_from_arn(string& tenant, string& url);
35 int store_url(const string& url, bool exclusive);
36 int read_url(const string& url, const string& tenant);
37 bool validate_input();
38
39public:
40 RGWOIDCProvider(CephContext *cct,
41 RGWCtl *ctl,
42 string provider_url,
43 string tenant,
44 vector<string> client_ids,
45 vector<string> thumbprints)
46 : cct(cct),
47 ctl(ctl),
48 provider_url(std::move(provider_url)),
49 tenant(std::move(tenant)),
50 client_ids(std::move(client_ids)),
51 thumbprints(std::move(thumbprints)) {
52 }
53
54 RGWOIDCProvider(CephContext *cct,
55 RGWCtl *ctl,
56 string arn,
57 string tenant)
58 : cct(cct),
59 ctl(ctl),
60 arn(std::move(arn)),
61 tenant(std::move(tenant)) {
62 }
63
64 RGWOIDCProvider(CephContext *cct,
65 RGWCtl *ctl,
66 string tenant)
67 : cct(cct),
68 ctl(ctl),
69 tenant(std::move(tenant)) {}
70
71 RGWOIDCProvider(CephContext *cct,
72 RGWCtl *ctl)
73 : cct(cct),
74 ctl(ctl) {}
75
76 RGWOIDCProvider() {}
77
78 ~RGWOIDCProvider() = default;
79
80 void encode(bufferlist& bl) const {
81 ENCODE_START(3, 1, bl);
82 encode(id, bl);
83 encode(provider_url, bl);
84 encode(arn, bl);
85 encode(creation_date, bl);
86 encode(tenant, bl);
87 encode(client_ids, bl);
88 encode(thumbprints, bl);
89 ENCODE_FINISH(bl);
90 }
91
92 void decode(bufferlist::const_iterator& bl) {
93 DECODE_START(2, bl);
94 decode(id, bl);
95 decode(provider_url, bl);
96 decode(arn, bl);
97 decode(creation_date, bl);
98 decode(tenant, bl);
99 decode(client_ids, bl);
100 decode(thumbprints, bl);
101 DECODE_FINISH(bl);
102 }
103
104 const string& get_provider_url() const { return provider_url; }
105 const string& get_arn() const { return arn; }
106 const string& get_create_date() const { return creation_date; }
107 const vector<string>& get_client_ids() const { return client_ids;}
108 const vector<string>& get_thumbprints() const { return thumbprints; }
109
110 int create(bool exclusive);
111 int delete_obj();
112 int get();
113 void dump(Formatter *f) const;
114 void dump_all(Formatter *f) const;
115 void decode_json(JSONObj *obj);
116
117 static const string& get_url_oid_prefix();
118 static int get_providers(RGWRados *store,
119 const string& tenant,
120 vector<RGWOIDCProvider>& providers);
121};
122WRITE_CLASS_ENCODER(RGWOIDCProvider)
123#endif /* CEPH_RGW_OIDC_PROVIDER_H */
124