]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Policies now properly evaluate the X-Forwarded-For header. 19819/head
authorJohn Gibson <jgibson@mitre.org>
Tue, 19 Sep 2017 13:17:22 +0000 (09:17 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Sun, 7 Jan 2018 10:15:23 +0000 (05:15 -0500)
Signed-off-by: John Gibson <jgibson@mitre.org>
(cherry picked from commit 5f7d9c4ff6c78f65d074dbdf8a181cb9ae09851e)

src/rgw/rgw_op.cc

index 4127d3254d4e8de212945a2281e9a74bc47a6555..65dd6db318433b6dc9a6ce36aafcda3631c487d5 100644 (file)
@@ -610,7 +610,16 @@ rgw::IAM::Environment rgw_build_iam_environment(RGWRados* store,
     i = m.find("REMOTE_ADDR");
   }
   if (i != m.end()) {
-    e.emplace("aws:SourceIp", i->second);
+    const string* ip = &(i->second);
+    string temp;
+    if (remote_addr_param == "HTTP_X_FORWARDED_FOR") {
+      const auto comma = ip->find(',');
+      if (comma != string::npos) {
+       temp.assign(*ip, 0, comma);
+       ip = &temp;
+      }
+    }
+    e.emplace("aws:SourceIp", *ip);
   }
 
   i = m.find("HTTP_USER_AGENT"); {