#include <boost/process.hpp>
#include "common/async/blocked_completion.h"
+#include "include/function2.hpp"
#include "common/Clock.h"
#include "common/errno.h"
return rgwrados::buckets::complete_flush_stats(dpp, y, rados, obj);
}
+int RadosStore::load_owner_by_email(const DoutPrefixProvider* dpp,
+ optional_yield y,
+ std::string_view email,
+ rgw_owner& owner)
+{
+ // the email index stores ids which can either be a user or account
+ RGWUID uid;
+ int r = svc()->user->read_email_index(dpp, y, email, uid);
+ if (r < 0) {
+ return r;
+ }
+ owner = parse_owner(uid.id);
+ return 0;
+}
+
std::unique_ptr<Object> RadosStore::get_object(const rgw_obj_key& k)
{
return std::make_unique<RadosObject>(this, k);
optional_yield y,
const rgw_owner& owner) override;
+ int load_owner_by_email(const DoutPrefixProvider* dpp,
+ optional_yield y,
+ std::string_view email,
+ rgw_owner& owner) override;
+
virtual std::unique_ptr<Object> get_object(const rgw_obj_key& k) override;
std::unique_ptr<Bucket> get_bucket(const RGWBucketInfo& i) override;
int load_bucket(const DoutPrefixProvider* dpp, const rgw_bucket& b,
string id_val = rgw_trim_quotes(id_val_quoted);
if (strcasecmp(id_type.c_str(), "emailAddress") == 0) {
- std::unique_ptr<rgw::sal::User> user;
- ret = driver->get_user_by_email(dpp, id_val, null_yield, &user);
+ ACLOwner owner;
+ ret = driver->load_aclowner_by_email(dpp, null_yield, id_val, owner);
if (ret < 0)
return ret;
- grant.set_canon(user->get_id(), user->get_display_name(), rgw_perm);
+ grant.set_canon(owner.id, owner.display_name, rgw_perm);
} else if (strcasecmp(id_type.c_str(), "id") == 0) {
std::unique_ptr<rgw::sal::User> user = driver->get_user(rgw_user(id_val));
ret = user->load_user(dpp, null_yield);
const uint32_t perm = xml_grant.permission->flags;
std::unique_ptr<rgw::sal::User> user;
+ ACLOwner owner;
switch (xml_grant.type.get_type()) {
case ACL_TYPE_EMAIL_USER:
if (xml_grant.email.empty()) {
return -EINVAL;
}
- if (driver->get_user_by_email(dpp, xml_grant.email, y, &user) < 0) {
+ if (driver->load_aclowner_by_email(dpp, y, xml_grant.email, owner) < 0) {
ldpp_dout(dpp, 10) << "grant user email not found or other error" << dendl;
err_msg = "The e-mail address you provided does not match any account on record.";
return -ERR_UNRESOLVABLE_EMAIL;
}
- grant.set_canon(user->get_id(), user->get_display_name(), perm);
+ grant.set_canon(owner.id, owner.display_name, perm);
return 0;
case ACL_TYPE_CANON_USER:
optional_yield y,
const rgw_owner& owner) = 0;
+ /** Look up the owner (user or account) for the given email address */
+ virtual int load_owner_by_email(const DoutPrefixProvider* dpp,
+ optional_yield y,
+ std::string_view email,
+ rgw_owner& owner) = 0;
+
/** Get a basic Object. This Object is not looked up, and is incomplete, since is
* does not have a bucket. This should only be used when an Object is needed before
* there is a Bucket, otherwise use the get_object() in the Bucket class. */
return 0;
}
+ int DBStore::load_owner_by_email(const DoutPrefixProvider* dpp,
+ optional_yield y,
+ std::string_view email,
+ rgw_owner& owner)
+ {
+ RGWUserInfo uinfo;
+ int ret = getDB()->get_user(dpp, "email", std::string{email},
+ uinfo, nullptr, nullptr);
+ if (ret < 0) {
+ return ret;
+ }
+ owner = std::move(uinfo.user_id);
+ return 0;
+ }
+
std::string DBStore::get_cluster_id(const DoutPrefixProvider* dpp, optional_yield y)
{
return "PLACEHOLDER"; // for instance unique identifier
optional_yield y,
const rgw_owner& owner) override;
+ int load_owner_by_email(const DoutPrefixProvider* dpp,
+ optional_yield y,
+ std::string_view email,
+ rgw_owner& owner) override;
virtual std::unique_ptr<Object> get_object(const rgw_obj_key& k) override;
virtual std::string get_cluster_id(const DoutPrefixProvider* dpp, optional_yield y);
std::unique_ptr<Bucket> get_bucket(const RGWBucketInfo& i) override;
return next->complete_flush_stats(dpp, y, owner);
}
+int FilterDriver::load_owner_by_email(const DoutPrefixProvider* dpp,
+ optional_yield y,
+ std::string_view email,
+ rgw_owner& owner)
+{
+ return next->load_owner_by_email(dpp, y, email, owner);
+}
+
std::unique_ptr<Object> FilterDriver::get_object(const rgw_obj_key& k)
{
std::unique_ptr<Object> o = next->get_object(k);
int complete_flush_stats(const DoutPrefixProvider* dpp,
optional_yield y,
const rgw_owner& owner) override;
-
+ int load_owner_by_email(const DoutPrefixProvider* dpp,
+ optional_yield y,
+ std::string_view email,
+ rgw_owner& owner) override;
virtual std::unique_ptr<Object> get_object(const rgw_obj_key& k) override;
std::unique_ptr<Bucket> get_bucket(const RGWBucketInfo& i) override;
int load_bucket(const DoutPrefixProvider* dpp, const rgw_bucket& b,
#include "rgw_service.h"
#include "rgw_sal_fwd.h"
-class RGWUserBuckets;
+struct RGWUID;
class RGWSI_User : public RGWServiceInstance
{
real_time *pmtime,
optional_yield y,
const DoutPrefixProvider *dpp) = 0;
+ virtual int read_email_index(const DoutPrefixProvider* dpp, optional_yield y,
+ std::string_view email, RGWUID& uid) = 0;
};
return 0;
}
+static int read_index(const DoutPrefixProvider* dpp, optional_yield y,
+ RGWSI_SysObj* svc_sysobj, const rgw_pool& pool,
+ const std::string& key, ceph::real_time* mtime,
+ RGWUID& uid)
+{
+ bufferlist bl;
+ int r = rgw_get_system_obj(svc_sysobj, pool, key, bl,
+ nullptr, mtime, y, dpp);
+ if (r < 0) {
+ return r;
+ }
+ try {
+ auto iter = bl.cbegin();
+ decode(uid, iter);
+ } catch (const buffer::error&) {
+ return -EIO;
+ }
+ return 0;
+}
+
int RGWSI_User_RADOS::get_user_info_from_index(RGWSI_MetaBackend::Context* ctx,
const string& key,
const rgw_pool& pool,
}
user_info_cache_entry e;
- bufferlist bl;
RGWUID uid;
- int ret = rgw_get_system_obj(svc.sysobj, pool, key, bl, nullptr, &e.mtime, y, dpp);
- if (ret < 0)
+ int ret = read_index(dpp, y, svc.sysobj, pool, key, &e.mtime, uid);
+ if (ret < 0) {
return ret;
-
- rgw_cache_entry_info cache_info;
-
- try {
- auto iter = bl.cbegin();
- decode(uid, iter);
- } catch (const buffer::error&) {
- ldpp_dout(dpp, 0) << "ERROR: failed to decode user info, caught buffer::error" << dendl;
- return -EIO;
}
if (rgw::account::validate_id(uid.id)) {
return -ENOENT;
}
+ rgw_cache_entry_info cache_info;
ret = read_user_info(ctx, rgw_user{uid.id}, &e.info, &e.objv_tracker,
nullptr, &cache_info, nullptr, y, dpp);
if (ret < 0) {
svc.zone->get_zone_params().user_keys_pool,
info, objv_tracker, pmtime, y, dpp);
}
+
+int RGWSI_User_RADOS::read_email_index(const DoutPrefixProvider* dpp,
+ optional_yield y,
+ std::string_view email,
+ RGWUID& uid)
+{
+ const rgw_pool& pool = svc.zone->get_zone_params().user_email_pool;
+ return read_index(dpp, y, svc.sysobj, pool, std::string{email}, nullptr, uid);
+}
real_time *pmtime,
optional_yield y,
const DoutPrefixProvider *dpp) override;
+
+ int read_email_index(const DoutPrefixProvider* dpp, optional_yield y,
+ std::string_view email, RGWUID& uid) override;
};