From: Adam C. Emerson Date: Thu, 14 Sep 2017 22:07:15 +0000 (-0400) Subject: rgw: Check payment operations in policy X-Git-Tag: v12.2.2~97^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=be1ded107ac4e1a1b1515d40553aed3581e0afac;p=ceph.git rgw: Check payment operations in policy Add code to check s3:GetBucketRequestPayment and s3:PutBucketRequestPayment operations against bucket policy. Fixes: http://tracker.ceph.com/issues/21389 Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1490278 Signed-off-by: Adam C. Emerson (cherry picked from commit f9d1ae1d153319e870c3ccaf7afdc92786cdaa3b) --- diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index f7e5caf67f51..9223618a3379 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -5070,6 +5070,12 @@ void RGWOptionsCORS::execute() int RGWGetRequestPayment::verify_permission() { + if (s->iam_policy && + s->iam_policy->eval(s->env, *s->auth.identity, + rgw::IAM::s3GetBucketRequestPayment, + ARN(s->bucket)) != Effect::Allow) { + return -EACCES; + } return 0; } @@ -5085,11 +5091,16 @@ void RGWGetRequestPayment::execute() int RGWSetRequestPayment::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::s3PutBucketRequestPayment, + 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 RGWSetRequestPayment::pre_exec()