From: Adam C. Emerson Date: Wed, 27 Sep 2017 19:42:27 +0000 (-0400) Subject: rgw: Check bucket CORS operations in policy X-Git-Tag: v12.2.2~100^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F18444%2Fhead;p=ceph.git rgw: Check bucket CORS operations in policy Add code to check s3:GetCORS and s3:PutCORS operations against bucket policy. Fixes: http://tracker.ceph.com/issues/21578 Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1494140 Signed-off-by: Adam C. Emerson (cherry picked from commit 27eb13fe568cc802feaf69131a21db076bcb6746) --- diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index f7e5caf67f5..1496bc52353 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -4921,11 +4921,16 @@ void RGWDeleteLC::execute() int RGWGetCORS::verify_permission() { - if (false == s->auth.identity->is_owner_of(s->bucket_owner.get_id())) { - return -EACCES; + if (s->iam_policy) { + if (s->iam_policy->eval(s->env, *s->auth.identity, + rgw::IAM::s3PutBucketCORS, + ARN(s->bucket)) == Effect::Allow) { + return 0; + } + } else if (s->auth.identity->is_owner_of(s->bucket_owner.get_id())) { + return 0; } - - return 0; + return -EACCES; } void RGWGetCORS::execute() @@ -4943,11 +4948,16 @@ void RGWGetCORS::execute() int RGWPutCORS::verify_permission() { - if (false == s->auth.identity->is_owner_of(s->bucket_owner.get_id())) { - return -EACCES; + if (s->iam_policy) { + if (s->iam_policy->eval(s->env, *s->auth.identity, + rgw::IAM::s3PutBucketCORS, + ARN(s->bucket)) == Effect::Allow) { + return 0; + } + } else if (s->auth.identity->is_owner_of(s->bucket_owner.get_id())) { + return 0; } - - return 0; + return -EACCES; } void RGWPutCORS::execute()