1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
4 #ifndef CEPH_RGW_OIDC_PROVIDER_H
5 #define CEPH_RGW_OIDC_PROVIDER_H
9 #include "common/ceph_context.h"
10 #include "common/ceph_json.h"
12 #include "rgw/rgw_rados.h"
18 using string
= std::string
;
19 static const string oidc_url_oid_prefix
;
20 static const string oidc_arn_prefix
;
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;
34 vector
<string
> client_ids
;
35 vector
<string
> thumbprints
;
37 int get_tenant_url_from_arn(string
& tenant
, string
& url
);
38 int store_url(const DoutPrefixProvider
*dpp
, const string
& url
, bool exclusive
, optional_yield y
);
39 int read_url(const DoutPrefixProvider
*dpp
, const string
& url
, const string
& tenant
);
40 bool validate_input();
43 RGWOIDCProvider(CephContext
*cct
,
47 vector
<string
> client_ids
,
48 vector
<string
> thumbprints
)
51 provider_url(std::move(provider_url
)),
52 tenant(std::move(tenant
)),
53 client_ids(std::move(client_ids
)),
54 thumbprints(std::move(thumbprints
)) {
57 RGWOIDCProvider(CephContext
*cct
,
64 tenant(std::move(tenant
)) {
67 RGWOIDCProvider(CephContext
*cct
,
72 tenant(std::move(tenant
)) {}
74 RGWOIDCProvider(CephContext
*cct
,
81 ~RGWOIDCProvider() = default;
83 void encode(bufferlist
& bl
) const {
84 ENCODE_START(3, 1, bl
);
86 encode(provider_url
, bl
);
88 encode(creation_date
, bl
);
90 encode(client_ids
, bl
);
91 encode(thumbprints
, bl
);
95 void decode(bufferlist::const_iterator
& bl
) {
98 decode(provider_url
, bl
);
100 decode(creation_date
, bl
);
102 decode(client_ids
, bl
);
103 decode(thumbprints
, bl
);
107 const string
& get_provider_url() const { return provider_url
; }
108 const string
& get_arn() const { return arn
; }
109 const string
& get_create_date() const { return creation_date
; }
110 const vector
<string
>& get_client_ids() const { return client_ids
;}
111 const vector
<string
>& get_thumbprints() const { return thumbprints
; }
113 int create(const DoutPrefixProvider
*dpp
, bool exclusive
, optional_yield y
);
114 int delete_obj(const DoutPrefixProvider
*dpp
, optional_yield y
);
115 int get(const DoutPrefixProvider
*dpp
);
116 void dump(Formatter
*f
) const;
117 void dump_all(Formatter
*f
) const;
118 void decode_json(JSONObj
*obj
);
120 static const string
& get_url_oid_prefix();
121 static int get_providers(const DoutPrefixProvider
*dpp
, RGWRados
*store
,
122 const string
& tenant
,
123 vector
<RGWOIDCProvider
>& providers
);
125 WRITE_CLASS_ENCODER(RGWOIDCProvider
)
126 #endif /* CEPH_RGW_OIDC_PROVIDER_H */