Skip to content

Commit b0350bf

Browse files
authored
Merge pull request ceph#61388 from AliMasarweh/wip-alimasa-bucket-logging-log-info
RGW\logging: added missing fields Reviewed-by: yuvalif<[email protected]>
2 parents 1fca955 + 9b7df3a commit b0350bf

File tree

4 files changed

+52
-8
lines changed

4 files changed

+52
-8
lines changed

src/rgw/rgw_asio_frontend.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,16 @@ void handle_connection(boost::asio::io_context& context,
323323
rgw::io::add_conlen_controlling(
324324
&real_client))));
325325
RGWRestfulIO client(cct, &real_client_io);
326+
// getting ssl_cipher and tls_version
327+
if(is_ssl) {
328+
ceph_assert(typeid(Stream) == typeid(boost::asio::ssl::stream<tcp::socket&>));
329+
const SSL * native_handle = reinterpret_cast<const SSL *>(stream.native_handle());
330+
const auto ssl_cipher = SSL_CIPHER_get_name(SSL_get_current_cipher(native_handle));
331+
const auto tls_version = SSL_get_version(native_handle);
332+
auto& client_env = client.get_env();
333+
client_env.set("SSL_CIPHER", ssl_cipher);
334+
client_env.set("TLS_VERSION", tls_version);
335+
}
326336
optional_yield y = null_yield;
327337
if (cct->_conf->rgw_beast_enable_async) {
328338
y = optional_yield{yield};

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: 14 additions & 8 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

@@ -481,13 +482,18 @@ int log_record(rgw::sal::Driver* driver,
481482
bucket_name = full_bucket_name(s->bucket);
482483
}
483484

485+
using namespace rgw::auth::s3;
486+
string aws_version("-");
487+
string auth_type("-");
488+
rgw::auth::s3::get_aws_version_and_auth_type(s, aws_version, auth_type);
489+
484490
switch (conf.logging_type) {
485491
case LoggingType::Standard:
486-
record = fmt::format("{} {} [{:%d/%b/%Y:%H:%M:%S %z}] {} {} {} {} {} \"{} {}{}{} HTTP/1.1\" {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}",
492+
record = fmt::format("{} {} [{:%d/%b/%Y:%H:%M:%S %z}] {} {} {} {} {} \"{} {}{}{} HTTP/1.1\" {} {} {} {} {} {} {} \"{}\" {} {} {} {} {} {} {} {} {}",
487493
dash_if_empty(bucket_owner),
488494
dash_if_empty(bucket_name),
489495
t,
490-
"-", // no requester IP
496+
s->info.env->get("REMOTE_ADDR", "-"),
491497
dash_if_empty(user_or_account),
492498
dash_if_empty(s->req_id),
493499
op_name,
@@ -502,15 +508,15 @@ int log_record(rgw::sal::Driver* driver,
502508
dash_if_zero(size),
503509
"-", // no total time when logging record
504510
std::chrono::duration_cast<std::chrono::milliseconds>(s->time_elapsed()),
505-
"-", // TODO: referer
506-
"-", // TODO: user agent
511+
s->info.env->get("HTTP_REFERER", "-"),
512+
s->info.env->get("HTTP_USER_AGENT", "-"),
507513
dash_if_empty_or_null(obj, obj->get_instance()),
508514
s->info.x_meta_map.contains("x-amz-id-2") ? s->info.x_meta_map.at("x-amz-id-2") : "-",
509-
"-", // TODO: Signature Version (SigV2 or SigV4)
510-
"-", // TODO: SSL cipher. e.g. "ECDHE-RSA-AES128-GCM-SHA256"
511-
"-", // TODO: Auth type. e.g. "AuthHeader"
515+
aws_version,
516+
s->info.env->get("SSL_CIPHER", "-"),
517+
auth_type,
512518
dash_if_empty(fqdn),
513-
"-", // TODO: TLS version. e.g. "TLSv1.2" or "TLSv1.3"
519+
s->info.env->get("TLS_VERSION", "-"),
514520
"-", // no access point ARN
515521
(s->has_acl_header) ? "Yes" : "-");
516522
break;

0 commit comments

Comments
 (0)