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: v13.0.2~635^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5f7d9c4ff6c78f65d074dbdf8a181cb9ae09851e;p=ceph.git rgw: Policies now properly evaluate the X-Forwarded-For header. Signed-off-by: John Gibson --- diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index edae45f2848..2bbc74e9c67 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -607,7 +607,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"); {