OPTION(rbd_cache_target_dirty, OPT_LONGLONG, 16<<20) // target dirty limit in bytes
OPTION(rbd_cache_max_dirty_age, OPT_FLOAT, 1.0) // seconds in cache before writeback starts
OPTION(rgw_data, OPT_STR, "/var/lib/ceph/radosgw/$cluster-$id")
+OPTION(rgw_enable_apis, OPT_STR, "s3, swift, swift_auth, admin")
OPTION(rgw_cache_enabled, OPT_BOOL, true) // rgw cache enabled
OPTION(rgw_cache_lru_size, OPT_INT, 10000) // num of entries in rgw cache
OPTION(rgw_socket_path, OPT_STR, "") // path to unix domain socket, if not specified, rgw will not run as external fcgi
OPTION(rgw_swift_url, OPT_STR, "") //
OPTION(rgw_swift_url_prefix, OPT_STR, "swift") //
OPTION(rgw_swift_auth_entry, OPT_STR, "auth") // entry point for which a url is considered a swift auth url
+OPTION(rgw_admin_entry, OPT_STR, "admin") // entry point for which a url is considered an admin request
OPTION(rgw_enforce_swift_acls, OPT_BOOL, true)
OPTION(rgw_print_continue, OPT_BOOL, true) // enable if 100-Continue works
OPTION(rgw_remote_addr_param, OPT_STR, "REMOTE_ADDR") // e.g. X-Forwarded-For, if you have a reverse proxy
f->close_section();
}
-bool RGWUserCaps::check_cap(const string& cap, uint32_t perm)
+int RGWUserCaps::check_cap(const string& cap, uint32_t perm)
{
map<string, uint32_t>::iterator iter = caps.find(cap);
- if (iter == caps.end())
- return false;
- return (iter->second & perm) == perm;
+ if ((iter == caps.end()) ||
+ (iter->second & perm) != perm) {
+ return -EPERM;
+ }
+
+ return 0;
}
::decode(caps, bl);
DECODE_FINISH(bl);
}
- bool check_cap(const string& cap, uint32_t perm);
+ int check_cap(const string& cap, uint32_t perm);
void dump(Formatter *f) const;
};
WRITE_CLASS_ENCODER(RGWUserCaps);
#include "common/WorkQueue.h"
#include "common/Timer.h"
#include "common/Throttle.h"
+#include "include/str_list.h"
#include "rgw_common.h"
#include "rgw_rados.h"
#include "rgw_acl.h"
RGWREST rest;
- rest.register_default_mgr(new RGWRESTMgr_S3);
- rest.register_resource(g_conf->rgw_swift_url_prefix, new RGWRESTMgr_SWIFT);
- rest.register_resource(g_conf->rgw_swift_auth_entry, new RGWRESTMgr_SWIFT_Auth);
+ list<string> apis;
- RGWRESTMgr_Admin *admin_resource = new RGWRESTMgr_Admin;
- admin_resource->register_resource("/usage", new RGWRESTMgr_Usage);
- rest.register_resource("/admin", admin_resource);
+ get_str_list(g_conf->rgw_enable_apis, apis);
+
+ map<string, bool> apis_map;
+ for (list<string>::iterator li = apis.begin(); li != apis.end(); ++li) {
+ apis_map[*li] = true;
+ }
+
+ if (apis_map.count("s3") > 0)
+ rest.register_default_mgr(new RGWRESTMgr_S3);
+
+ if (apis_map.count("swift") > 0)
+ rest.register_resource(g_conf->rgw_swift_url_prefix, new RGWRESTMgr_SWIFT);
+
+ if (apis_map.count("swift_auth") > 0)
+ rest.register_resource(g_conf->rgw_swift_auth_entry, new RGWRESTMgr_SWIFT_Auth);
+
+ if (apis_map.count("admin") > 0) {
+ RGWRESTMgr_Admin *admin_resource = new RGWRESTMgr_Admin;
+ admin_resource->register_resource("usage", new RGWRESTMgr_Usage);
+ rest.register_resource(g_conf->rgw_admin_entry, admin_resource);
+ }
RGWProcess process(g_ceph_context, g_conf->rgw_thread_pool_size, &rest);
process.run();
flusher.flush();
}
+int RGWRESTOp::verify_permission()
+{
+ return check_caps(s->user.caps);
+}
+
static void line_unfold(const char *line, string& sdest)
{
char dest[strlen(line) + 1];
void RGWRESTMgr::register_resource(string resource, RGWRESTMgr *mgr)
{
- resource_mgrs[resource] = mgr;
- resources_by_size[resource.size()] = resource;
+ string r = "/";
+ r.append(resource);
+ resource_mgrs[r] = mgr;
+ resources_by_size.insert(pair<size_t, string>(r.size(), r));
}
void RGWRESTMgr::register_default_mgr(RGWRESTMgr *mgr)
if (resources_by_size.empty())
return this;
- map<size_t, string>::reverse_iterator iter;
+ multimap<size_t, string>::reverse_iterator iter;
for (iter = resources_by_size.rbegin(); iter != resources_by_size.rend(); ++iter) {
string& resource = iter->second;
flusher.init(s);
}
virtual void send_response();
+ virtual int check_caps(RGWUserCaps& caps) { return -EPERM; } /* should to be implemented! */
+ virtual int verify_permission();
};
class RGWHandler_ObjStore : public RGWHandler {
class RGWRESTMgr {
protected:
map<string, RGWRESTMgr *> resource_mgrs;
- map<size_t, string> resources_by_size;
+ multimap<size_t, string> resources_by_size;
RGWRESTMgr *default_mgr;
public:
#include "rgw_usage.h"
#include "rgw_rest_usage.h"
+#define dout_subsys ceph_subsys_rgw
+
class RGWOp_Usage_Get : public RGWRESTOp {
public:
RGWOp_Usage_Get() {}
- int verify_permission() { return 0; }
+ int check_caps(RGWUserCaps& caps) {
+ return caps.check_cap("usage", RGW_CAP_READ);
+ }
void execute();
virtual const char *name() { return "get_usage"; }
public:
RGWOp_Usage_Delete() {}
- int verify_permission() { return 0; }
+ int check_caps(RGWUserCaps& caps) {
+ return caps.check_cap("usage", RGW_CAP_WRITE);
+ }
void execute();
virtual const char *name() { return "trim_usage"; }
int read_permissions(RGWOp*) {
return 0;
}
- int authorize() {
- return 0;
- }
};
class RGWRESTMgr_Usage : public RGWRESTMgr {