rgw: Policies now properly evaluate the X-Forwarded-For header.

Signed-off-by: John Gibson <jgibson@mitre.org>
This commit is contained in:
John Gibson 2017-09-19 09:17:22 -04:00
parent e02facbf5c
commit 5f7d9c4ff6
No known key found for this signature in database
GPG Key ID: 3C1AA9D440584354

View File

@ -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"); {