From: Ali Masarwa Date: Mon, 9 Dec 2024 10:53:05 +0000 (+0200) Subject: RGW\log: adding some missing members X-Git-Tag: v20.0.0~354^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=0377e1cd8f35096692456648a122e0dfd261cf9b;p=ceph.git RGW\log: adding some missing members Signed-off-by: Ali Masarwa --- diff --git a/src/rgw/rgw_auth_s3.cc b/src/rgw/rgw_auth_s3.cc index 4fe1e39d0a8d0..5f2d400b188b1 100644 --- a/src/rgw/rgw_auth_s3.cc +++ b/src/rgw/rgw_auth_s3.cc @@ -1741,4 +1741,30 @@ std::string get_canonical_method(const DoutPrefixProvider *dpp, RGWOpType op_typ return info.method; } + +void get_aws_version_and_auth_type(const req_state* s, string& aws_version, string& auth_type) +{ + const char* http_auth = s->info.env->get("HTTP_AUTHORIZATION"); + if (http_auth && http_auth[0]) { + auth_type = "AuthHeader"; + /* Authorization in Header */ + if (!strncmp(http_auth, AWS4_HMAC_SHA256_STR, + strlen(AWS4_HMAC_SHA256_STR))) { + /* AWS v4 */ + aws_version = "SigV4"; + } else if (!strncmp(http_auth, "AWS ", 4)) { + /* AWS v2 */ + aws_version = "SigV2"; + } + } else { + auth_type = "QueryString"; + if (s->info.args.get("x-amz-algorithm") == AWS4_HMAC_SHA256_STR) { + /* AWS v4 */ + aws_version = "SigV4"; + } else if (!s->info.args.get("AWSAccessKeyId").empty()) { + /* AWS v2 */ + aws_version = "SigV2"; + } + } +} } // namespace rgw::auth::s3 diff --git a/src/rgw/rgw_auth_s3.h b/src/rgw/rgw_auth_s3.h index 2f7fd2d75985c..a14989b067c20 100644 --- a/src/rgw/rgw_auth_s3.h +++ b/src/rgw/rgw_auth_s3.h @@ -746,6 +746,8 @@ get_v2_signature(CephContext*, const AWSEngine::VersionAbstractor::string_to_sign_t& string_to_sign); std::string get_canonical_method(const DoutPrefixProvider *dpp, RGWOpType op_type, const req_info& info); + +void get_aws_version_and_auth_type(const req_state* s, string& aws_version, string& auth_type); } /* namespace s3 */ } /* namespace auth */ } /* namespace rgw */ diff --git a/src/rgw/rgw_bucket_logging.cc b/src/rgw/rgw_bucket_logging.cc index 87a242d9952b2..50eaa5478b49a 100644 --- a/src/rgw/rgw_bucket_logging.cc +++ b/src/rgw/rgw_bucket_logging.cc @@ -8,6 +8,7 @@ #include "rgw_xml.h" #include "rgw_sal.h" #include "rgw_op.h" +#include "rgw_auth_s3.h" #define dout_subsys ceph_subsys_rgw @@ -411,6 +412,11 @@ int log_record(rgw::sal::Driver* driver, bucket_name = s->bucket->get_name(); } + using namespace rgw::auth::s3; + string aws_version("-"); + string auth_type("-"); + rgw::auth::s3::get_aws_version_and_auth_type(s, aws_version, auth_type); + switch (conf.logging_type) { case LoggingType::Standard: record = fmt::format("{} {} [{:%d/%b/%Y:%H:%M:%S %z}] {} {} {} {} {} \"{} {}{}{} HTTP/1.1\" {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}", @@ -432,13 +438,13 @@ int log_record(rgw::sal::Driver* driver, dash_if_zero(size), "-", // no total time when logging record std::chrono::duration_cast(s->time_elapsed()), - "-", // TODO: referer - "-", // TODO: user agent + s->info.env->get("HTTP_REFERER", "-"), + s->info.env->get("HTTP_USER_AGENT", "-"), dash_if_empty_or_null(obj, obj->get_instance()), s->info.x_meta_map.contains("x-amz-id-2") ? s->info.x_meta_map.at("x-amz-id-2") : "-", - "-", // TODO: Signature Version (SigV2 or SigV4) + aws_version, "-", // TODO: SSL cipher. e.g. "ECDHE-RSA-AES128-GCM-SHA256" - "-", // TODO: Auth type. e.g. "AuthHeader" + auth_type, dash_if_empty(fqdn), "-", // TODO: TLS version. e.g. "TLSv1.2" or "TLSv1.3" "-", // no access point ARN