]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/rgw/rgw_role.h
update sources to v12.1.0
[ceph.git] / ceph / src / rgw / rgw_role.h
index f8a60a4c5680d50195bcfb6f3dd421235241f1c4..bccb576ed2d83c1e023d6687bcd22321e1afa929 100644 (file)
@@ -7,6 +7,8 @@ class RGWRole
   static const string role_oid_prefix;
   static const string role_path_oid_prefix;
   static const string role_arn_prefix;
+  static constexpr int MAX_ROLE_NAME_LEN = 64;
+  static constexpr int MAX_PATH_NAME_LEN = 512;
 
   CephContext *cct;
   RGWRados *store;
@@ -17,15 +19,17 @@ class RGWRole
   string creation_date;
   string trust_policy;
   map<string, string> perm_policy_map;
-  string uid;
+  string tenant;
 
   int store_info(bool exclusive);
   int store_name(bool exclusive);
   int store_path(bool exclusive);
-  int read_id(const string& role_name, string& role_id);
+  int read_id(const string& role_name, const string& tenant, string& role_id);
   int read_name();
   int read_info();
   void set_id(const string& id) { this->id = id; }
+  bool validate_input();
+  void extract_name_tenant(const std::string& str);
 
 public:
   RGWRole(CephContext *cct,
@@ -33,23 +37,35 @@ public:
           string name,
           string path,
           string trust_policy,
-          string uid)
+          string tenant)
   : cct(cct),
     store(store),
     name(std::move(name)),
     path(std::move(path)),
     trust_policy(std::move(trust_policy)),
-    uid(std::move(uid)) {
+    tenant(std::move(tenant)) {
     if (this->path.empty())
       this->path = "/";
+    extract_name_tenant(this->name);
   }
 
   RGWRole(CephContext *cct,
           RGWRados *store,
-          string name)
+          string name,
+          string tenant)
+  : cct(cct),
+    store(store),
+    name(std::move(name)),
+    tenant(std::move(tenant)) {
+    extract_name_tenant(this->name);
+  }
+
+  RGWRole(CephContext *cct,
+          RGWRados *store,
+          string id)
   : cct(cct),
     store(store),
-    name(std::move(name)) {}
+    id(std::move(id)) {}
 
   RGWRole(CephContext *cct,
           RGWRados *store)
@@ -61,7 +77,7 @@ public:
   ~RGWRole() = default;
 
   void encode(bufferlist& bl) const {
-    ENCODE_START(1, 1, bl);
+    ENCODE_START(2, 1, bl);
     ::encode(id, bl);
     ::encode(name, bl);
     ::encode(path, bl);
@@ -69,11 +85,12 @@ public:
     ::encode(creation_date, bl);
     ::encode(trust_policy, bl);
     ::encode(perm_policy_map, bl);
+    ::encode(tenant, bl);
     ENCODE_FINISH(bl);
   }
 
   void decode(bufferlist::iterator& bl) {
-    DECODE_START(1, bl);
+    DECODE_START(2, bl);
     ::decode(id, bl);
     ::decode(name, bl);
     ::decode(path, bl);
@@ -81,6 +98,9 @@ public:
     ::decode(creation_date, bl);
     ::decode(trust_policy, bl);
     ::decode(perm_policy_map, bl);
+    if (struct_v >= 2) {
+      ::decode(tenant, bl);
+    }
     DECODE_FINISH(bl);
   }
 
@@ -88,10 +108,12 @@ public:
   const string& get_name() const { return name; }
   const string& get_path() const { return path; }
   const string& get_create_date() const { return creation_date; }
+  const string& get_assume_role_policy() const { return trust_policy;}
 
   int create(bool exclusive);
   int delete_obj();
   int get();
+  int get_by_id();
   int update();
   void update_trust_policy(string& trust_policy);
   void set_perm_policy(const string& policy_name, const string& perm_policy);
@@ -104,7 +126,11 @@ public:
   static const string& get_names_oid_prefix();
   static const string& get_info_oid_prefix();
   static const string& get_path_oid_prefix();
-  static int get_roles_by_path_prefix(RGWRados *store, CephContext *cct, const string& path_prefix, vector<RGWRole>& roles);
+  static int get_roles_by_path_prefix(RGWRados *store,
+                                      CephContext *cct,
+                                      const string& path_prefix,
+                                      const string& tenant,
+                                      vector<RGWRole>& roles);
 };
 WRITE_CLASS_ENCODER(RGWRole)
 #endif /* CEPH_RGW_ROLE_H */