]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/rgw/rgw_oidc_provider.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / rgw / rgw_oidc_provider.h
index 4b6ecda9d76c310b005f08595332bbb4976f30ba..c3b794df0d62a2e444bb329a0f377d67b8b5d548 100644 (file)
@@ -9,76 +9,74 @@
 #include "common/ceph_context.h"
 #include "common/ceph_json.h"
 
-#include "rgw/rgw_rados.h"
+#include "rgw/rgw_sal.h"
 
-class RGWCtl;
+namespace rgw { namespace sal {
 
 class RGWOIDCProvider
 {
-  using string = std::string;
-  static const string oidc_url_oid_prefix;
-  static const string oidc_arn_prefix;
+public:
+  static const std::string oidc_url_oid_prefix;
+  static const std::string oidc_arn_prefix;
   static constexpr int MAX_OIDC_NUM_CLIENT_IDS = 100;
   static constexpr int MAX_OIDC_CLIENT_ID_LEN = 255;
   static constexpr int MAX_OIDC_NUM_THUMBPRINTS = 5;
   static constexpr int MAX_OIDC_THUMBPRINT_LEN = 40;
   static constexpr int MAX_OIDC_URL_LEN = 255;
 
-  CephContext *cct;
-  RGWCtl *ctl;
-  string id;
-  string provider_url;
-  string arn;
-  string creation_date;
-  string tenant;
-  vector<string> client_ids;
-  vector<string> thumbprints;
-
-  int get_tenant_url_from_arn(string& tenant, string& url);
-  int store_url(const DoutPrefixProvider *dpp, const string& url, bool exclusive, optional_yield y);
-  int read_url(const DoutPrefixProvider *dpp, const string& url, const string& tenant);
-  bool validate_input();
+protected:
+  std::string id;
+  std::string provider_url;
+  std::string arn;
+  std::string creation_date;
+  std::string tenant;
+  std::vector<std::string> client_ids;
+  std::vector<std::string> thumbprints;
+
+  int get_tenant_url_from_arn(std::string& tenant, std::string& url);
+  virtual int store_url(const DoutPrefixProvider *dpp, const std::string& url, bool exclusive, optional_yield y) = 0;
+  virtual int read_url(const DoutPrefixProvider *dpp, const std::string& url, const std::string& tenant) = 0;
+  bool validate_input(const DoutPrefixProvider *dpp);
 
 public:
-  RGWOIDCProvider(CephContext *cct,
-                    RGWCtl *ctl,
-                    string provider_url,
-                    string tenant,
-                    vector<string> client_ids,
-                    vector<string> thumbprints)
-  : cct(cct),
-    ctl(ctl),
-    provider_url(std::move(provider_url)),
+  void set_arn(std::string _arn) {
+    arn = _arn;
+  }
+  void set_url(std::string _provider_url) {
+    provider_url = _provider_url;
+  }
+  void set_tenant(std::string _tenant) {
+    tenant = _tenant;
+  }
+  void set_client_ids(std::vector<std::string>& _client_ids) {
+    client_ids = std::move(_client_ids);
+  }
+  void set_thumbprints(std::vector<std::string>& _thumbprints) {
+    thumbprints = std::move(_thumbprints);
+  }
+
+  RGWOIDCProvider(std::string provider_url,
+                    std::string tenant,
+                    std::vector<std::string> client_ids,
+                    std::vector<std::string> thumbprints)
+  : provider_url(std::move(provider_url)),
     tenant(std::move(tenant)),
     client_ids(std::move(client_ids)),
     thumbprints(std::move(thumbprints)) {
   }
 
-  RGWOIDCProvider(CephContext *cct,
-                    RGWCtl *ctl,
-                    string arn,
-                    string tenant)
-  : cct(cct),
-    ctl(ctl),
-    arn(std::move(arn)),
+  RGWOIDCProvider( std::string arn,
+                    std::string tenant)
+  : arn(std::move(arn)),
     tenant(std::move(tenant)) {
   }
 
-  RGWOIDCProvider(CephContext *cct,
-                    RGWCtl *ctl,
-                    string tenant)
-  : cct(cct),
-    ctl(ctl),
-    tenant(std::move(tenant)) {}
-
-  RGWOIDCProvider(CephContext *cct,
-          RGWCtl *ctl)
-  : cct(cct),
-    ctl(ctl) {}
+  RGWOIDCProvider(std::string tenant)
+  : tenant(std::move(tenant)) {}
 
   RGWOIDCProvider() {}
 
-  ~RGWOIDCProvider() = default;
+  virtual ~RGWOIDCProvider() = default;
 
   void encode(bufferlist& bl) const {
     ENCODE_START(3, 1, bl);
@@ -104,24 +102,23 @@ public:
     DECODE_FINISH(bl);
   }
 
-  const string& get_provider_url() const { return provider_url; }
-  const string& get_arn() const { return arn; }
-  const string& get_create_date() const { return creation_date; }
-  const vector<string>& get_client_ids() const { return client_ids;}
-  const vector<string>& get_thumbprints() const { return thumbprints; }
+  const std::string& get_provider_url() const { return provider_url; }
+  const std::string& get_arn() const { return arn; }
+  const std::string& get_create_date() const { return creation_date; }
+  const std::vector<std::string>& get_client_ids() const { return client_ids;}
+  const std::vector<std::string>& get_thumbprints() const { return thumbprints; }
 
   int create(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y);
-  int delete_obj(const DoutPrefixProvider *dpp, optional_yield y);
+  virtual int delete_obj(const DoutPrefixProvider *dpp, optional_yield y) = 0;
   int get(const DoutPrefixProvider *dpp);
   void dump(Formatter *f) const;
   void dump_all(Formatter *f) const;
   void decode_json(JSONObj *obj);
 
-  static const string& get_url_oid_prefix();
-  static int get_providers(const DoutPrefixProvider *dpp, RGWRados *store,
-                            const string& tenant,
-                            vector<RGWOIDCProvider>& providers);
+  static const std::string& get_url_oid_prefix();
 };
 WRITE_CLASS_ENCODER(RGWOIDCProvider)
+
+} } // namespace rgw::sal
 #endif /* CEPH_RGW_OIDC_PROVIDER_H */