Skip to content

Commit 1d7c204

Browse files
author
Liam Monahan
committed
Add a configurable to allow bucket perms to be checked before key perms
through rgw_defer_to_bucket_acls config option. This configurable defaults to an empty string. Option values include: - recurse: If requesting perm PERM on a key, allow if user has PERM on the bucket to which the key belongs. - full_control: If requesting perm PERM on a key, allow if user has FULL_CONTROL on the bucket to which the key belongs. This allows users to give someone full bucket perms and be able to operate on the keys in the bucket without modifying the perms of every key in the bucket. This breaks S3 compatability, but that's why it's a configurable! Signed-off-by: Liam Monahan <liam@umiacs.umd.edu>
1 parent 1bdc3f7 commit 1d7c204

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

src/common/config_opts.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,7 @@ OPTION(rgw_exit_timeout_secs, OPT_INT, 120) // how many seconds to wait for proc
706706
OPTION(rgw_get_obj_window_size, OPT_INT, 16 << 20) // window size in bytes for single get obj request
707707
OPTION(rgw_get_obj_max_req_size, OPT_INT, 4 << 20) // max length of a single get obj rados op
708708
OPTION(rgw_relaxed_s3_bucket_names, OPT_BOOL, false) // enable relaxed bucket name rules for US region buckets
709+
OPTION(rgw_defer_to_bucket_acls, OPT_STR, "") // if the user has bucket perms, use those before key perms (recurse and full_control)
709710
OPTION(rgw_list_buckets_max_chunk, OPT_INT, 1000) // max buckets to retrieve in a single op when listing user buckets
710711
OPTION(rgw_md_log_max_shards, OPT_INT, 64) // max shards for metadata log
711712
OPTION(rgw_num_zone_opstate_shards, OPT_INT, 128) // max shards for keeping inter-region copy progress info

src/rgw/rgw_common.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ req_state::req_state(CephContext *_cct, class RGWEnv *e) : cct(_cct), cio(NULL),
128128
{
129129
enable_ops_log = e->conf->enable_ops_log;
130130
enable_usage_log = e->conf->enable_usage_log;
131+
defer_to_bucket_acls = e->conf->defer_to_bucket_acls;
131132
content_started = false;
132133
format = 0;
133134
formatter = NULL;
@@ -618,8 +619,18 @@ bool verify_bucket_permission(struct req_state *s, int perm)
618619
return s->bucket_acl->verify_permission(s->user.user_id, perm, perm);
619620
}
620621

622+
static inline bool check_deferred_bucket_acl(struct req_state *s, uint8_t deferred_check, int perm)
623+
{
624+
return (s->defer_to_bucket_acls == deferred_check && verify_bucket_permission(s, perm));
625+
}
626+
621627
bool verify_object_permission(struct req_state *s, RGWAccessControlPolicy *bucket_acl, RGWAccessControlPolicy *object_acl, int perm)
622628
{
629+
if (check_deferred_bucket_acl(s, RGW_DEFER_TO_BUCKET_ACLS_RECURSE, perm) ||
630+
check_deferred_bucket_acl(s, RGW_DEFER_TO_BUCKET_ACLS_FULL_CONTROL, RGW_PERM_FULL_CONTROL)) {
631+
return true;
632+
}
633+
623634
if (!object_acl)
624635
return false;
625636

src/rgw/rgw_common.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ using ceph::crypto::MD5;
9494

9595
#define RGW_DEFAULT_MAX_BUCKETS 1000
9696

97+
#define RGW_DEFER_TO_BUCKET_ACLS_RECURSE 1
98+
#define RGW_DEFER_TO_BUCKET_ACLS_FULL_CONTROL 2
99+
97100
#define STATUS_CREATED 1900
98101
#define STATUS_ACCEPTED 1901
99102
#define STATUS_NO_CONTENT 1902
@@ -295,10 +298,11 @@ class RGWConf {
295298
void init(CephContext *cct, RGWEnv * env);
296299
public:
297300
RGWConf() :
298-
enable_ops_log(1), enable_usage_log(1) {}
301+
enable_ops_log(1), enable_usage_log(1), defer_to_bucket_acls(0) {}
299302

300303
int enable_ops_log;
301304
int enable_usage_log;
305+
uint8_t defer_to_bucket_acls;
302306
};
303307

304308
enum http_op {
@@ -798,6 +802,7 @@ struct req_state {
798802
uint64_t obj_size;
799803
bool enable_ops_log;
800804
bool enable_usage_log;
805+
uint8_t defer_to_bucket_acls;
801806
uint32_t perm_mask;
802807
utime_t header_time;
803808

src/rgw/rgw_env.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,11 @@ void RGWConf::init(CephContext *cct, RGWEnv *env)
108108
{
109109
enable_ops_log = cct->_conf->rgw_enable_ops_log;
110110
enable_usage_log = cct->_conf->rgw_enable_usage_log;
111+
112+
defer_to_bucket_acls = 0; // default
113+
if (cct->_conf->rgw_defer_to_bucket_acls == "recurse") {
114+
defer_to_bucket_acls = RGW_DEFER_TO_BUCKET_ACLS_RECURSE;
115+
} else if (cct->_conf->rgw_defer_to_bucket_acls == "full_control") {
116+
defer_to_bucket_acls = RGW_DEFER_TO_BUCKET_ACLS_FULL_CONTROL;
117+
}
111118
}

0 commit comments

Comments
 (0)