Skip to content

Conversation

@gmjehovich
Copy link
Contributor

Note: This PR includes changes from #136299 which must merge first.

This is currently a draft which adds Audit Logging to CrossClusterAccessAuthenticationService. Relevant files that are changed

  • CrossClusterAccessAuthenticationService.java (audit logging calls)
  • CrossClusterAccessAuthenticationServiceTests.java (new tests)
  • AuditTrail.java (new method signature)
  • LoggingAuditTrail.java (new method implementation)

Changes

  • Added authenticationFailed(requestId, token, action, remoteAddress) overload to AuditTrail
  • Modified tryAuthenticate() to call audit trail on authentication failures
  • Added unit tests verifying audit logging behavior

Testing Approach

Audit logging is tested via unit tests with mocked AuditTrail to verify we're calling the audit trail with the correct parameters for both success and failure scenarios.

I initially looked at AuditIT which reads audit logs from the test cluster, but it uses the newer ElasticsearchCluster test framework with log file access via cluster.getNodeLog(). The existing CrossClusterAccessAuthenticationServiceIntegTests uses internalCluster() which doesn't provide the same convenient API for log access, as far as I can tell.

However, I've started adding integration test audit verification by accessing the audit log files directly through the Environment and NodeEnvironment services available in internalCluster(); this code is present in CrossClusterAccessAuthenticationIntegTests.verifyAuditLogs. This allows reading the actual audit log to verify end-to-end audit trail behavior. The integration test audit verification is still being fleshed out but I think this approach is viable.

jfreden and others added 17 commits October 3, 2025 15:26
…e identity verification, header verification
# Conflicts: #	x-pack/plugin/security/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/xpack/remotecluster/RemoteClusterSecurityCrossClusterApiKeySigningIT.java #	x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ApiKeyService.java #	x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ApiKeyServiceTests.java #	x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/CrossClusterAccessAuthenticationServiceIntegTests.java
Rebase audit logging changes on top of latest signature verififcation changes
@gmjehovich
Copy link
Contributor Author

Closing. After further investigation with @jfreden, we determined there is not a need to add this new audit logging in the authenticateHeaders path

@gmjehovich gmjehovich closed this Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3 participants