]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Check payment operations in policy
authorAdam C. Emerson <aemerson@redhat.com>
Thu, 14 Sep 2017 22:07:15 +0000 (18:07 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Wed, 27 Sep 2017 17:58:32 +0000 (13:58 -0400)
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 <aemerson@redhat.com>
src/rgw/rgw_op.cc

index 39a5dee9b7158b292394870537b776fefa121307..2632550d218b67b27ac987756fc33969410c047f 100644 (file)
@@ -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()