]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: policy: reuse eval_principal to evaluate the policy principal 36303/head
authorAbhishek Lekshmanan <abhishek@suse.com>
Mon, 27 Jul 2020 14:58:30 +0000 (16:58 +0200)
committerAbhishek Lekshmanan <abhishek@suse.com>
Mon, 27 Jul 2020 14:58:30 +0000 (16:58 +0200)
Since the other edge case when no Principal or a NotPrincipal is supplied also
must be accounted for, which is already done in eval_principal function. Also
reraising the error as Effect::Pass in line with the previous output, though an
Effect::Deny would also work here.

Fixes: https://tracker.ceph.com/issues/46078
Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>
src/rgw/rgw_iam_policy.cc

index 3dfcc187587c886f9c2518631acca1d3224d2a3f..2265334a76f427b6de1ef993b1ec11eff3733ba0 100644 (file)
@@ -977,12 +977,9 @@ ostream& operator <<(ostream& m, const Condition& c) {
 Effect Statement::eval(const Environment& e,
                       boost::optional<const rgw::auth::Identity&> ida,
                       uint64_t act, const ARN& res) const {
-  if (ida) {
-    if (!princ.empty() && !ida->is_identity(princ)) {
-      return Effect::Pass;
-    } else if (!noprinc.empty() && ida->is_identity(noprinc)) {
-      return Effect::Pass;
-    }
+
+  if (eval_principal(e, ida) == Effect::Deny) {
+    return Effect::Pass;
   }
 
   if (!resource.empty()) {