From: Adam C. Emerson Date: Thu, 14 Sep 2017 22:07:15 +0000 (-0400) Subject: rgw: Check payment operations in policy X-Git-Tag: v13.0.1~753^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f9d1ae1d153319e870c3ccaf7afdc92786cdaa3b;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 --- diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 39a5dee9b71..2632550d218 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -5084,6 +5084,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; } @@ -5099,11 +5105,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()