class RGWGetUserStats_CB;
namespace rgw { namespace sal {
-class RGWRadosStore;
+class Store;
} }
/**
{
rgw_user user_id;
void encode(bufferlist& bl) const {
- string s;
+ std::string s;
user_id.to_str(s);
using ceph::encode;
encode(s, bl);
}
void decode(bufferlist::const_iterator& bl) {
- string s;
+ std::string s;
using ceph::decode;
decode(s, bl);
user_id.from_str(s);
};
WRITE_CLASS_ENCODER(RGWUID)
-extern int rgw_user_sync_all_stats(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *store, const rgw_user& user_id, optional_yield y);
+/** Entry for bucket metadata collection */
+struct bucket_meta_entry {
+ size_t size;
+ size_t size_rounded;
+ ceph::real_time creation_time;
+ uint64_t count;
+};
+
+extern int rgw_user_sync_all_stats(const DoutPrefixProvider *dpp, rgw::sal::Store* store, rgw::sal::User* user, optional_yield y);
extern int rgw_user_get_all_buckets_stats(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,const rgw_user& user_id,
- map<string, cls_user_bucket_entry>& buckets_usage_map, optional_yield y);
+ rgw::sal::Store* store, rgw::sal::User* user,
+ std::map<std::string, bucket_meta_entry>& buckets_usage_map, optional_yield y);
/**
* Get the anonymous (ie, unauthenticated) user info.
*/
extern void rgw_get_anon_user(RGWUserInfo& info);
-/**
- * Save the given user information to storage.
- * Returns: 0 on success, -ERR# on failure.
- */
-extern int rgw_store_user_info(const DoutPrefixProvider *dpp,
- RGWUserCtl *user_ctl,
- RGWUserInfo& info,
- RGWUserInfo *old_info,
- RGWObjVersionTracker *objv_tracker,
- real_time mtime,
- bool exclusive,
- optional_yield y,
- map<string, bufferlist> *pattrs = nullptr);
-
-/**
- * Given an user_id, finds the user info associated with it.
- * returns: 0 on success, -ERR# on failure (including nonexistence)
- */
-extern int rgw_get_user_info_by_uid(const DoutPrefixProvider *dpp,
- RGWUserCtl *user_ctl,
- const rgw_user& user_id,
- RGWUserInfo& info,
- optional_yield y,
- RGWObjVersionTracker *objv_tracker = nullptr,
- real_time *pmtime = nullptr,
- rgw_cache_entry_info *cache_info = nullptr,
- map<string, bufferlist> *pattrs = nullptr);
-/**
- * Given an email, finds the user info associated with it.
- * returns: 0 on success, -ERR# on failure (including nonexistence)
- */
-extern int rgw_get_user_info_by_email(const DoutPrefixProvider *dpp,
- RGWUserCtl *user_ctl,
- string& email, RGWUserInfo& info,
- optional_yield y,
- RGWObjVersionTracker *objv_tracker = NULL,
- real_time *pmtime = nullptr);
-/**
- * Given an swift username, finds the user info associated with it.
- * returns: 0 on success, -ERR# on failure (including nonexistence)
- */
-extern int rgw_get_user_info_by_swift(const DoutPrefixProvider *dpp,
- RGWUserCtl *user_ctl,
- const string& swift_name,
- RGWUserInfo& info, /* out */
- optional_yield y,
- RGWObjVersionTracker *objv_tracker = nullptr,
- real_time *pmtime = nullptr);
-/**
- * Given an access key, finds the user info associated with it.
- * returns: 0 on success, -ERR# on failure (including nonexistence)
- */
-extern int rgw_get_user_info_by_access_key(const DoutPrefixProvider *dpp,
- RGWUserCtl *user_ctl,
- const std::string& access_key,
- RGWUserInfo& info,
- optional_yield y,
- RGWObjVersionTracker* objv_tracker = nullptr,
- real_time* pmtime = nullptr);
-
extern void rgw_perm_to_str(uint32_t mask, char *buf, int len);
extern uint32_t rgw_str_to_perm(const char *str);
-extern int rgw_validate_tenant_name(const string& t);
+extern int rgw_validate_tenant_name(const std::string& t);
enum ObjectKeyType {
KEY_TYPE_SWIFT,
*/
struct RGWUserAdminOpState {
// user attributes
- RGWUserInfo info;
- rgw_user user_id;
+ std::unique_ptr<rgw::sal::User> user;
std::string user_email;
std::string display_name;
rgw_user new_user_id;
bool overwrite_new_user = false;
- int32_t max_buckets;
- __u8 suspended;
- __u8 admin;
- __u8 system;
- __u8 exclusive;
- __u8 fetch_stats;
- __u8 sync_stats;
+ int32_t max_buckets{RGW_DEFAULT_MAX_BUCKETS};
+ __u8 suspended{0};
+ __u8 admin{0};
+ __u8 system{0};
+ __u8 exclusive{0};
+ __u8 fetch_stats{0};
+ __u8 sync_stats{0};
std::string caps;
RGWObjVersionTracker objv;
- uint32_t op_mask;
- map<int, string> temp_url_keys;
+ uint32_t op_mask{0};
+ std::map<int, std::string> temp_url_keys;
// subuser attributes
std::string subuser;
- uint32_t perm_mask;
+ uint32_t perm_mask{RGW_PERM_NONE};
// key_attributes
std::string id; // access key
std::string key; // secret key
- int32_t key_type;
+ int32_t key_type{-1};
+ bool access_key_exist = false;
- std::set<string> mfa_ids;
+ std::set<std::string> mfa_ids;
// operation attributes
- bool existing_user;
- bool existing_key;
- bool existing_subuser;
- bool existing_email;
- bool subuser_specified;
- bool gen_secret;
- bool gen_access;
- bool gen_subuser;
- bool id_specified;
- bool key_specified;
- bool type_specified;
- bool key_type_setbycontext; // key type set by user or subuser context
- bool purge_data;
- bool purge_keys;
- bool display_name_specified;
- bool user_email_specified;
- bool max_buckets_specified;
- bool perm_specified;
- bool op_mask_specified;
- bool caps_specified;
- bool suspension_op;
- bool admin_specified = false;
- bool system_specified;
- bool key_op;
- bool temp_url_key_specified;
- bool found_by_uid;
- bool found_by_email;
- bool found_by_key;
- bool mfa_ids_specified;
+ bool existing_user{false};
+ bool existing_key{false};
+ bool existing_subuser{false};
+ bool existing_email{false};
+ bool subuser_specified{false};
+ bool gen_secret{false};
+ bool gen_access{false};
+ bool gen_subuser{false};
+ bool id_specified{false};
+ bool key_specified{false};
+ bool type_specified{false};
+ bool key_type_setbycontext{false}; // key type set by user or subuser context
+ bool purge_data{false};
+ bool purge_keys{false};
+ bool display_name_specified{false};
+ bool user_email_specified{false};
+ bool max_buckets_specified{false};
+ bool perm_specified{false};
+ bool op_mask_specified{false};
+ bool caps_specified{false};
+ bool suspension_op{false};
+ bool admin_specified{false};
+ bool system_specified{false};
+ bool key_op{false};
+ bool temp_url_key_specified{false};
+ bool found_by_uid{false};
+ bool found_by_email{false};
+ bool found_by_key{false};
+ bool mfa_ids_specified{false};
// req parameters
- bool populated;
- bool initialized;
- bool key_params_checked;
- bool subuser_params_checked;
- bool user_params_checked;
+ bool populated{false};
+ bool initialized{false};
+ bool key_params_checked{false};
+ bool subuser_params_checked{false};
+ bool user_params_checked{false};
- bool bucket_quota_specified;
- bool user_quota_specified;
+ bool bucket_quota_specified{false};
+ bool user_quota_specified{false};
+ bool bucket_ratelimit_specified{false};
+ bool user_ratelimit_specified{false};
RGWQuotaInfo bucket_quota;
RGWQuotaInfo user_quota;
+ RGWRateLimitInfo user_ratelimit;
+ RGWRateLimitInfo bucket_ratelimit;
// req parameters for listing user
- std::string marker;
- uint32_t max_entries;
+ std::string marker{""};
+ uint32_t max_entries{1000};
rgw_placement_rule default_placement; // user default placement
- bool default_placement_specified;
+ bool default_placement_specified{false};
- list<string> placement_tags; // user default placement_tags
- bool placement_tags_specified;
+ std::list<std::string> placement_tags; // user default placement_tags
+ bool placement_tags_specified{false};
void set_access_key(const std::string& access_key) {
if (access_key.empty())
key_op = true;
}
- void set_user_id(rgw_user& id) {
- if (id.empty())
- return;
+ void set_user_id(const rgw_user& id);
- user_id = id;
- }
-
- void set_new_user_id(rgw_user& id) {
+ void set_new_user_id(const rgw_user& id) {
if (id.empty())
return;
display_name_specified = true;
}
- void set_subuser(std::string& _subuser) {
- if (_subuser.empty())
- return;
-
- size_t pos = _subuser.find(":");
- if (pos != string::npos) {
- rgw_user tmp_id;
- tmp_id.from_str(_subuser.substr(0, pos));
- if (tmp_id.tenant.empty()) {
- user_id.id = tmp_id.id;
- } else {
- user_id = tmp_id;
- }
- subuser = _subuser.substr(pos+1);
- } else {
- subuser = _subuser;
- }
-
- subuser_specified = true;
- }
+ void set_subuser(std::string& _subuser);
void set_caps(const std::string& _caps) {
if (_caps.empty())
op_mask_specified = true;
}
- void set_temp_url_key(const string& key, int index) {
+ void set_temp_url_key(const std::string& key, int index) {
temp_url_keys[index] = key;
temp_url_key_specified = true;
}
type_specified = true;
}
+ void set_access_key_exist() {
+ access_key_exist = true;
+ }
+
void set_suspension(__u8 is_suspended) {
suspended = is_suspended;
suspension_op = true;
sync_stats = is_sync_stats;
}
- void set_user_info(RGWUserInfo& user_info) {
- user_id = user_info.user_id;
- info = user_info;
- }
+ void set_user_info(RGWUserInfo& user_info);
void set_max_buckets(int32_t mb) {
max_buckets = mb;
user_quota_specified = true;
}
- void set_mfa_ids(const std::set<string>& ids) {
+ void set_bucket_ratelimit(RGWRateLimitInfo& ratelimit) {
+ bucket_ratelimit = ratelimit;
+ bucket_ratelimit_specified = true;
+ }
+
+ void set_user_ratelimit(RGWRateLimitInfo& ratelimit) {
+ user_ratelimit = ratelimit;
+ user_ratelimit_specified = true;
+ }
+
+ void set_mfa_ids(const std::set<std::string>& ids) {
mfa_ids = ids;
mfa_ids_specified = true;
}
default_placement_specified = true;
}
- void set_placement_tags(const list<string>& _tags) {
+ void set_placement_tags(const std::list<std::string>& _tags) {
placement_tags = _tags;
placement_tags_specified = true;
}
void set_generate_subuser(bool flag) { gen_subuser = flag; }
__u8 get_suspension_status() { return suspended; }
int32_t get_key_type() {return key_type; }
+ bool get_access_key_exist() {return access_key_exist; }
uint32_t get_subuser_perm() { return perm_mask; }
int32_t get_max_buckets() { return max_buckets; }
uint32_t get_op_mask() { return op_mask; }
RGWQuotaInfo& get_bucket_quota() { return bucket_quota; }
RGWQuotaInfo& get_user_quota() { return user_quota; }
- set<string>& get_mfa_ids() { return mfa_ids; }
+ std::set<std::string>& get_mfa_ids() { return mfa_ids; }
- rgw_user& get_user_id() { return user_id; }
+ rgw::sal::User* get_user() { return user.get(); }
+ const rgw_user& get_user_id();
std::string get_subuser() { return subuser; }
std::string get_access_key() { return id; }
std::string get_secret_key() { return key; }
std::string get_display_name() { return display_name; }
rgw_user& get_new_uid() { return new_user_id; }
bool get_overwrite_new_user() const { return overwrite_new_user; }
- map<int, std::string>& get_temp_url_keys() { return temp_url_keys; }
-
- RGWUserInfo& get_user_info() { return info; }
-
- map<std::string, RGWAccessKey> *get_swift_keys() { return &info.swift_keys; }
- map<std::string, RGWAccessKey> *get_access_keys() { return &info.access_keys; }
- map<std::string, RGWSubUser> *get_subusers() { return &info.subusers; }
+ std::map<int, std::string>& get_temp_url_keys() { return temp_url_keys; }
- RGWUserCaps *get_caps_obj() { return &info.caps; }
+ RGWUserInfo& get_user_info();
- std::string build_default_swift_kid() {
- if (user_id.empty() || subuser.empty())
- return "";
+ std::map<std::string, RGWAccessKey>* get_swift_keys();
+ std::map<std::string, RGWAccessKey>* get_access_keys();
+ std::map<std::string, RGWSubUser>* get_subusers();
- std::string kid;
- user_id.to_str(kid);
- kid.append(":");
- kid.append(subuser);
+ RGWUserCaps* get_caps_obj();
- return kid;
- }
-
- std::string generate_subuser() {
- if (user_id.empty())
- return "";
-
- std::string generated_subuser;
- user_id.to_str(generated_subuser);
- std::string rand_suffix;
-
- int sub_buf_size = RAND_SUBUSER_LEN + 1;
- char sub_buf[RAND_SUBUSER_LEN + 1];
-
- gen_rand_alphanumeric_upper(g_ceph_context, sub_buf, sub_buf_size);
-
- rand_suffix = sub_buf;
- if (rand_suffix.empty())
- return "";
+ std::string build_default_swift_kid();
- generated_subuser.append(rand_suffix);
- subuser = generated_subuser;
+ std::string generate_subuser();
- return generated_subuser;
- }
-
- RGWUserAdminOpState() : user_id(RGW_USER_ANON_ID)
- {
- max_buckets = RGW_DEFAULT_MAX_BUCKETS;
- key_type = -1;
- perm_mask = RGW_PERM_NONE;
- suspended = 0;
- admin = 0;
- system = 0;
- exclusive = 0;
- fetch_stats = 0;
- op_mask = 0;
-
- existing_user = false;
- existing_key = false;
- existing_subuser = false;
- existing_email = false;
- subuser_specified = false;
- caps_specified = false;
- purge_keys = false;
- gen_secret = false;
- gen_access = false;
- gen_subuser = false;
- id_specified = false;
- key_specified = false;
- type_specified = false;
- key_type_setbycontext = false;
- purge_data = false;
- display_name_specified = false;
- user_email_specified = false;
- max_buckets_specified = false;
- perm_specified = false;
- op_mask_specified = false;
- suspension_op = false;
- system_specified = false;
- key_op = false;
- populated = false;
- initialized = false;
- key_params_checked = false;
- subuser_params_checked = false;
- user_params_checked = false;
- bucket_quota_specified = false;
- temp_url_key_specified = false;
- user_quota_specified = false;
- found_by_uid = false;
- found_by_email = false;
- found_by_key = false;
- mfa_ids_specified = false;
- default_placement_specified = false;
- placement_tags_specified = false;
- max_entries = 1000;
- marker = "";
- }
+ RGWUserAdminOpState(rgw::sal::Store* store);
};
class RGWUser;
std::map<std::string, int, ltstr_nocase> key_type_map;
rgw_user user_id;
- rgw::sal::RGWRadosStore *store{nullptr};
- RGWUserCtl *user_ctl{nullptr};
+ rgw::sal::Store* store{nullptr};
- map<std::string, RGWAccessKey> *swift_keys{nullptr};
- map<std::string, RGWAccessKey> *access_keys{nullptr};
+ std::map<std::string, RGWAccessKey> *swift_keys{nullptr};
+ std::map<std::string, RGWAccessKey> *access_keys{nullptr};
// we don't want to allow keys for the anonymous user or a null user
bool keys_allowed{false};
RGWUser *user{nullptr};
rgw_user user_id;
- rgw::sal::RGWRadosStore *store{nullptr};
- RGWUserCtl *user_ctl{nullptr};
+ rgw::sal::Store* store{nullptr};
bool subusers_allowed{false};
- map<string, RGWSubUser> *subuser_map{nullptr};
+ std::map<std::string, RGWSubUser> *subuser_map{nullptr};
private:
int check_op(RGWUserAdminOpState& op_state, std::string *err_msg = NULL);
private:
RGWUserInfo old_info;
- rgw::sal::RGWRadosStore *store{nullptr};
- RGWUserCtl *user_ctl{nullptr};
+ rgw::sal::Store* store{nullptr};
rgw_user user_id;
bool info_stored{false};
public:
RGWUser();
- int init(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *storage, RGWUserAdminOpState& op_state,
+ int init(const DoutPrefixProvider *dpp, rgw::sal::Store* storage, RGWUserAdminOpState& op_state,
optional_yield y);
- int init_storage(rgw::sal::RGWRadosStore *storage);
+ int init_storage(rgw::sal::Store* storage);
int init(const DoutPrefixProvider *dpp, RGWUserAdminOpState& op_state, optional_yield y);
int init_members(RGWUserAdminOpState& op_state);
- rgw::sal::RGWRadosStore *get_store() { return store; }
- RGWUserCtl *get_user_ctl() { return user_ctl; }
+ rgw::sal::Store* get_store() { return store; }
/* API Contracted Members */
RGWUserCapPool caps;
class RGWUserAdminOp_User
{
public:
- static int list(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *store,
+ static int list(const DoutPrefixProvider *dpp, rgw::sal::Store* store,
RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher);
- static int info(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+ static int info(const DoutPrefixProvider *dpp,
+ rgw::sal::Store* store,
RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher,
optional_yield y);
- static int create(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+ static int create(const DoutPrefixProvider *dpp,
+ rgw::sal::Store* store,
RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher,
optional_yield y);
- static int modify(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *store,
+ static int modify(const DoutPrefixProvider *dpp,
+ rgw::sal::Store* store,
RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher, optional_yield y);
- static int remove(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *store,
+ static int remove(const DoutPrefixProvider *dpp, rgw::sal::Store* store,
RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher, optional_yield y);
};
class RGWUserAdminOp_Subuser
{
public:
- static int create(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+ static int create(const DoutPrefixProvider *dpp,
+ rgw::sal::Store* store,
RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher,
optional_yield y);
- static int modify(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+ static int modify(const DoutPrefixProvider *dpp,
+ rgw::sal::Store* store,
RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher,
optional_yield y);
- static int remove(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+ static int remove(const DoutPrefixProvider *dpp,
+ rgw::sal::Store* store,
RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher,
optional_yield y);
};
class RGWUserAdminOp_Key
{
public:
- static int create(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *store,
+ static int create(const DoutPrefixProvider *dpp, rgw::sal::Store* store,
RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher,
optional_yield y);
- static int remove(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+ static int remove(const DoutPrefixProvider *dpp,
+ rgw::sal::Store* store,
RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher,
optional_yield y);
};
class RGWUserAdminOp_Caps
{
public:
- static int add(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+ static int add(const DoutPrefixProvider *dpp,
+ rgw::sal::Store* store,
RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher,
optional_yield y);
- static int remove(const DoutPrefixProvider *dpp,
- rgw::sal::RGWRadosStore *store,
+ static int remove(const DoutPrefixProvider *dpp,
+ rgw::sal::Store* store,
RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher,
optional_yield y);
};
struct RGWUserCompleteInfo {
RGWUserInfo info;
- map<string, bufferlist> attrs;
+ std::map<std::string, bufferlist> attrs;
bool has_attrs{false};
void dump(Formatter * const f) const {
RGWObjVersionTracker *objv_tracker{nullptr};
ceph::real_time *mtime{nullptr};
rgw_cache_entry_info *cache_info{nullptr};
- map<string, bufferlist> *attrs{nullptr};
+ std::map<std::string, bufferlist> *attrs{nullptr};
GetParams() {}
return *this;
}
- GetParams& set_attrs(map<string, bufferlist> *_attrs) {
+ GetParams& set_attrs(std::map<std::string, bufferlist> *_attrs) {
attrs = _attrs;
return *this;
}
RGWObjVersionTracker *objv_tracker{nullptr};
ceph::real_time mtime;
bool exclusive{false};
- map<string, bufferlist> *attrs{nullptr};
+ std::map<std::string, bufferlist> *attrs{nullptr};
PutParams() {}
return *this;
}
- PutParams& set_attrs(map<string, bufferlist> *_attrs) {
+ PutParams& set_attrs(std::map<std::string, bufferlist> *_attrs) {
attrs = _attrs;
return *this;
}
const rgw_user& uid, RGWUserInfo *info,
optional_yield y, const GetParams& params = {});
int get_info_by_email(const DoutPrefixProvider *dpp,
- const string& email, RGWUserInfo *info,
+ const std::string& email, RGWUserInfo *info,
optional_yield y, const GetParams& params = {});
int get_info_by_swift(const DoutPrefixProvider *dpp,
- const string& swift_name, RGWUserInfo *info,
+ const std::string& swift_name, RGWUserInfo *info,
optional_yield y, const GetParams& params = {});
int get_info_by_access_key(const DoutPrefixProvider *dpp,
- const string& access_key, RGWUserInfo *info,
+ const std::string& access_key, RGWUserInfo *info,
optional_yield y, const GetParams& params = {});
int get_attrs_by_uid(const DoutPrefixProvider *dpp,
const rgw_user& user_id,
- map<string, bufferlist> *attrs,
+ std::map<std::string, bufferlist> *attrs,
optional_yield y,
RGWObjVersionTracker *objv_tracker = nullptr);
const rgw_bucket& bucket, optional_yield y);
int list_buckets(const DoutPrefixProvider *dpp,
const rgw_user& user,
- const string& marker,
- const string& end_marker,
+ const std::string& marker,
+ const std::string& end_marker,
uint64_t max,
bool need_stats,
RGWUserBuckets *buckets,