1 #ifndef CEPH_RGW_ROLE_H
2 #define CEPH_RGW_ROLE_H
6 static const string role_name_oid_prefix;
7 static const string role_oid_prefix;
8 static const string role_path_oid_prefix;
9 static const string role_arn_prefix;
10 static constexpr int MAX_ROLE_NAME_LEN = 64;
11 static constexpr int MAX_PATH_NAME_LEN = 512;
21 map<string, string> perm_policy_map;
24 int store_info(bool exclusive);
25 int store_name(bool exclusive);
26 int store_path(bool exclusive);
27 int read_id(const string& role_name, const string& tenant, string& role_id);
30 void set_id(const string& id) { this->id = id; }
31 bool validate_input();
32 void extract_name_tenant(const std::string& str);
35 RGWRole(CephContext *cct,
43 name(std::move(name)),
44 path(std::move(path)),
45 trust_policy(std::move(trust_policy)),
46 tenant(std::move(tenant)) {
47 if (this->path.empty())
49 extract_name_tenant(this->name);
52 RGWRole(CephContext *cct,
58 name(std::move(name)),
59 tenant(std::move(tenant)) {
60 extract_name_tenant(this->name);
63 RGWRole(CephContext *cct,
70 RGWRole(CephContext *cct,
79 void encode(bufferlist& bl) const {
80 ENCODE_START(2, 1, bl);
85 ::encode(creation_date, bl);
86 ::encode(trust_policy, bl);
87 ::encode(perm_policy_map, bl);
92 void decode(bufferlist::iterator& bl) {
98 ::decode(creation_date, bl);
99 ::decode(trust_policy, bl);
100 ::decode(perm_policy_map, bl);
102 ::decode(tenant, bl);
107 const string& get_id() const { return id; }
108 const string& get_name() const { return name; }
109 const string& get_path() const { return path; }
110 const string& get_create_date() const { return creation_date; }
111 const string& get_assume_role_policy() const { return trust_policy;}
113 int create(bool exclusive);
118 void update_trust_policy(string& trust_policy);
119 void set_perm_policy(const string& policy_name, const string& perm_policy);
120 vector<string> get_role_policy_names();
121 int get_role_policy(const string& policy_name, string& perm_policy);
122 int delete_policy(const string& policy_name);
123 void dump(Formatter *f) const;
124 void decode_json(JSONObj *obj);
126 static const string& get_names_oid_prefix();
127 static const string& get_info_oid_prefix();
128 static const string& get_path_oid_prefix();
129 static int get_roles_by_path_prefix(RGWRados *store,
131 const string& path_prefix,
132 const string& tenant,
133 vector<RGWRole>& roles);
135 WRITE_CLASS_ENCODER(RGWRole)
136 #endif /* CEPH_RGW_ROLE_H */