From: John Gibson Date: Tue, 19 Sep 2017 13:17:22 +0000 (-0400) Subject: rgw: Policies now properly evaluate the X-Forwarded-For header. X-Git-Tag: v12.2.3~207^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F19819%2Fhead;p=ceph.git rgw: Policies now properly evaluate the X-Forwarded-For header. Signed-off-by: John Gibson (cherry picked from commit 5f7d9c4ff6c78f65d074dbdf8a181cb9ae09851e) --- diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 4127d3254d4e..65dd6db31843 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -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"); {