Skip to content

Commit

Permalink
Set audit events to be created by @memcached/Local
Browse files Browse the repository at this point in the history
Change-Id: I16f87c500d32fd6e620ffafaa29fef209f7d2b59
Reviewed-on: https://review.couchbase.org/c/kv_engine/+/182075
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
  • Loading branch information
trondn committed Nov 1, 2022
1 parent b4db923 commit e795882
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 3 additions & 4 deletions auditd/src/audit.cc
Expand Up @@ -79,10 +79,9 @@ AuditImpl::~AuditImpl() {
void AuditImpl::create_audit_event(uint32_t event_id, nlohmann::json& payload) {
// Add common fields to the audit event
payload["timestamp"] = ISOTime::generatetimestamp();
nlohmann::json real_userid;
real_userid["domain"] = "internal";
real_userid["user"] = "couchbase";
payload["real_userid"] = real_userid;
const cb::rbac::UserIdent real_userid("@memcached",
cb::rbac::Domain::Local);
payload["real_userid"] = real_userid.to_json();

switch (event_id) {
case AUDITD_AUDIT_CONFIGURED_AUDIT_DAEMON:
Expand Down
4 changes: 4 additions & 0 deletions tests/testapp/testapp_audit.cc
Expand Up @@ -250,6 +250,10 @@ TEST_P(AuditTest, AuditConfigured) {
// this is the entry I want
EXPECT_EQ(2, entry["version"].get<int>());
EXPECT_EQ("this_is_the_uuid", entry["uuid"].get<std::string>());
EXPECT_EQ("local",
entry["real_userid"]["domain"].get<std::string>());
EXPECT_EQ("@memcached",
entry["real_userid"]["user"].get<std::string>());
found = true;
return true;
}
Expand Down

0 comments on commit e795882

Please sign in to comment.