diff --git a/extensions-core/druid-basic-security/src/main/java/org/apache/druid/security/basic/authentication/endpoint/BasicAuthenticatorResource.java b/extensions-core/druid-basic-security/src/main/java/org/apache/druid/security/basic/authentication/endpoint/BasicAuthenticatorResource.java index 60e84faaf289..7881fcd5343a 100644 --- a/extensions-core/druid-basic-security/src/main/java/org/apache/druid/security/basic/authentication/endpoint/BasicAuthenticatorResource.java +++ b/extensions-core/druid-basic-security/src/main/java/org/apache/druid/security/basic/authentication/endpoint/BasicAuthenticatorResource.java @@ -160,7 +160,7 @@ public Response createUser( authValidator.validateAuthenticatorName(authenticatorName); final Response response = handler.createUser(authenticatorName, userName); - performAudit(authenticatorName, "basicAuth.createUser", userName, req, response); + performAuditIfSuccess(authenticatorName, "basicAuth.createUser", userName, req, response); return response; } @@ -186,7 +186,7 @@ public Response deleteUser( { authValidator.validateAuthenticatorName(authenticatorName); final Response response = handler.deleteUser(authenticatorName, userName); - performAudit(authenticatorName, "basicAuth.deleteUser", userName, req, response); + performAuditIfSuccess(authenticatorName, "basicAuth.deleteUser", userName, req, response); return response; } @@ -213,7 +213,7 @@ public Response updateUserCredentials( { authValidator.validateAuthenticatorName(authenticatorName); final Response response = handler.updateUserCredentials(authenticatorName, userName, update); - performAudit(authenticatorName, "basicAuth.updateUserCreds", userName, req, response); + performAuditIfSuccess(authenticatorName, "basicAuth.updateUserCreds", userName, req, response); return response; } @@ -265,7 +265,7 @@ private boolean isSuccess(Response response) return responseCode >= 200 && responseCode < 300; } - private void performAudit( + private void performAuditIfSuccess( String authenticatorName, String action, String updatedUser, diff --git a/server/src/main/java/org/apache/druid/server/security/AuthorizationUtils.java b/server/src/main/java/org/apache/druid/server/security/AuthorizationUtils.java index d05e7cb49040..431819da8a42 100644 --- a/server/src/main/java/org/apache/druid/server/security/AuthorizationUtils.java +++ b/server/src/main/java/org/apache/druid/server/security/AuthorizationUtils.java @@ -131,6 +131,9 @@ public static AuditInfo buildAuditInfo(HttpServletRequest request) ); } + /** + * Builds a RequestInfo object that can be used for auditing purposes. + */ public static RequestInfo buildRequestInfo(String service, HttpServletRequest request) { return new RequestInfo( diff --git a/server/src/test/java/org/apache/druid/metadata/SQLMetadataRuleManagerTest.java b/server/src/test/java/org/apache/druid/metadata/SQLMetadataRuleManagerTest.java index 940b770d0868..5a9fc0f13b01 100644 --- a/server/src/test/java/org/apache/druid/metadata/SQLMetadataRuleManagerTest.java +++ b/server/src/test/java/org/apache/druid/metadata/SQLMetadataRuleManagerTest.java @@ -74,7 +74,9 @@ public void setUp() tablesConfig = derbyConnectorRule.metadataTablesConfigSupplier().get(); connector.createAuditTable(); auditManager = new SQLAuditManager( - new SQLAuditManagerConfig(), null, connector, + new SQLAuditManagerConfig(), + null, + connector, Suppliers.ofInstance(tablesConfig), new NoopServiceEmitter(), mapper diff --git a/server/src/test/java/org/apache/druid/server/http/CoordinatorCompactionConfigsResourceTest.java b/server/src/test/java/org/apache/druid/server/http/CoordinatorCompactionConfigsResourceTest.java index 6d65e4acdbcc..c31364ac9fd9 100644 --- a/server/src/test/java/org/apache/druid/server/http/CoordinatorCompactionConfigsResourceTest.java +++ b/server/src/test/java/org/apache/druid/server/http/CoordinatorCompactionConfigsResourceTest.java @@ -148,8 +148,6 @@ public void testSetCompactionTaskLimitWithExistingConfig() double compactionTaskSlotRatio = 0.5; int maxCompactionTaskSlots = 9; - String author = "maytas"; - String comment = "hello"; Response result = coordinatorCompactionConfigsResource.setCompactionTaskLimit( compactionTaskSlotRatio, maxCompactionTaskSlots, @@ -193,8 +191,6 @@ public void testAddOrUpdateCompactionConfigWithExistingConfig() null, ImmutableMap.of("key", "val") ); - String author = "maytas"; - String comment = "hello"; Response result = coordinatorCompactionConfigsResource.addOrUpdateCompactionConfig( newConfig, mockHttpServletRequest @@ -244,8 +240,6 @@ public void testDeleteCompactionConfigWithExistingConfig() ) ).thenReturn(originalConfig); - String author = "maytas"; - String comment = "hello"; Response result = coordinatorCompactionConfigsResource.deleteCompactionConfig( datasourceName, mockHttpServletRequest @@ -341,8 +335,6 @@ public void testSetCompactionTaskLimitWithoutExistingConfig() double compactionTaskSlotRatio = 0.5; int maxCompactionTaskSlots = 9; - String author = "maytas"; - String comment = "hello"; Response result = coordinatorCompactionConfigsResource.setCompactionTaskLimit( compactionTaskSlotRatio, maxCompactionTaskSlots, @@ -427,8 +419,6 @@ public void testDeleteCompactionConfigWithoutExistingConfigShouldFailAsDatasourc ArgumentMatchers.eq(CoordinatorCompactionConfig.empty()) ) ).thenReturn(CoordinatorCompactionConfig.empty()); - String author = "maytas"; - String comment = "hello"; Response result = coordinatorCompactionConfigsResource.deleteCompactionConfig( DATASOURCE_NOT_EXISTS, mockHttpServletRequest diff --git a/web-console/src/dialogs/history-dialog/history-dialog.tsx b/web-console/src/dialogs/history-dialog/history-dialog.tsx index 6b7f219e6471..d204f316d3ed 100644 --- a/web-console/src/dialogs/history-dialog/history-dialog.tsx +++ b/web-console/src/dialogs/history-dialog/history-dialog.tsx @@ -60,7 +60,7 @@ export const HistoryDialog = React.memo(function HistoryDialog(props: HistoryDia let content: JSX.Element; if (historyRecords.length === 0) { - content =