]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
RGW\log: adding some missing members
authorAli Masarwa <amasarwa@redhat.com>
Mon, 9 Dec 2024 10:53:05 +0000 (12:53 +0200)
committerAli Masarwa <amasarwa@redhat.com>
Wed, 15 Jan 2025 14:19:09 +0000 (16:19 +0200)
Signed-off-by: Ali Masarwa <amasarwa@redhat.com>
src/rgw/rgw_auth_s3.cc
src/rgw/rgw_auth_s3.h
src/rgw/rgw_bucket_logging.cc

index 4fe1e39d0a8d0d2b2fc9b117ca102f0ce39ad31a..5f2d400b188b1836e0874b93d45a6fed83fec3c7 100644 (file)
@@ -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
index 2f7fd2d75985c730ba7c797f86817e7f65e3289f..a14989b067c205e6ddc29f6064bc88d713087032 100644 (file)
@@ -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 */
index 87a242d9952b2d7de65aad0f809fa97631b1464b..50eaa5478b49af40e2dff62d16e5474d51130dac 100644 (file)
@@ -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<std::chrono::milliseconds>(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