Skip to content

Commit 0377e1c

Browse files
committed
RGW\log: adding some missing members
Signed-off-by: Ali Masarwa <[email protected]>
1 parent bb40fe4 commit 0377e1c

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

src/rgw/rgw_auth_s3.cc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,4 +1741,30 @@ std::string get_canonical_method(const DoutPrefixProvider *dpp, RGWOpType op_typ
17411741

17421742
return info.method;
17431743
}
1744+
1745+
void get_aws_version_and_auth_type(const req_state* s, string& aws_version, string& auth_type)
1746+
{
1747+
const char* http_auth = s->info.env->get("HTTP_AUTHORIZATION");
1748+
if (http_auth && http_auth[0]) {
1749+
auth_type = "AuthHeader";
1750+
/* Authorization in Header */
1751+
if (!strncmp(http_auth, AWS4_HMAC_SHA256_STR,
1752+
strlen(AWS4_HMAC_SHA256_STR))) {
1753+
/* AWS v4 */
1754+
aws_version = "SigV4";
1755+
} else if (!strncmp(http_auth, "AWS ", 4)) {
1756+
/* AWS v2 */
1757+
aws_version = "SigV2";
1758+
}
1759+
} else {
1760+
auth_type = "QueryString";
1761+
if (s->info.args.get("x-amz-algorithm") == AWS4_HMAC_SHA256_STR) {
1762+
/* AWS v4 */
1763+
aws_version = "SigV4";
1764+
} else if (!s->info.args.get("AWSAccessKeyId").empty()) {
1765+
/* AWS v2 */
1766+
aws_version = "SigV2";
1767+
}
1768+
}
1769+
}
17441770
} // namespace rgw::auth::s3

src/rgw/rgw_auth_s3.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,8 @@ get_v2_signature(CephContext*,
746746
const AWSEngine::VersionAbstractor::string_to_sign_t& string_to_sign);
747747

748748
std::string get_canonical_method(const DoutPrefixProvider *dpp, RGWOpType op_type, const req_info& info);
749+
750+
void get_aws_version_and_auth_type(const req_state* s, string& aws_version, string& auth_type);
749751
} /* namespace s3 */
750752
} /* namespace auth */
751753
} /* namespace rgw */

src/rgw/rgw_bucket_logging.cc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "rgw_xml.h"
99
#include "rgw_sal.h"
1010
#include "rgw_op.h"
11+
#include "rgw_auth_s3.h"
1112

1213
#define dout_subsys ceph_subsys_rgw
1314

@@ -411,6 +412,11 @@ int log_record(rgw::sal::Driver* driver,
411412
bucket_name = s->bucket->get_name();
412413
}
413414

415+
using namespace rgw::auth::s3;
416+
string aws_version("-");
417+
string auth_type("-");
418+
rgw::auth::s3::get_aws_version_and_auth_type(s, aws_version, auth_type);
419+
414420
switch (conf.logging_type) {
415421
case LoggingType::Standard:
416422
record = fmt::format("{} {} [{:%d/%b/%Y:%H:%M:%S %z}] {} {} {} {} {} \"{} {}{}{} HTTP/1.1\" {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}",
@@ -432,13 +438,13 @@ int log_record(rgw::sal::Driver* driver,
432438
dash_if_zero(size),
433439
"-", // no total time when logging record
434440
std::chrono::duration_cast<std::chrono::milliseconds>(s->time_elapsed()),
435-
"-", // TODO: referer
436-
"-", // TODO: user agent
441+
s->info.env->get("HTTP_REFERER", "-"),
442+
s->info.env->get("HTTP_USER_AGENT", "-"),
437443
dash_if_empty_or_null(obj, obj->get_instance()),
438444
s->info.x_meta_map.contains("x-amz-id-2") ? s->info.x_meta_map.at("x-amz-id-2") : "-",
439-
"-", // TODO: Signature Version (SigV2 or SigV4)
445+
aws_version,
440446
"-", // TODO: SSL cipher. e.g. "ECDHE-RSA-AES128-GCM-SHA256"
441-
"-", // TODO: Auth type. e.g. "AuthHeader"
447+
auth_type,
442448
dash_if_empty(fqdn),
443449
"-", // TODO: TLS version. e.g. "TLSv1.2" or "TLSv1.3"
444450
"-", // no access point ARN

0 commit comments

Comments
 (0)