Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/spring boot 2.x accumulo 2.1 #12

Merged
merged 64 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
b167b7f
Updated to spring boot 2.4.4
jwomeara Apr 2, 2021
70ad87f
Updated profile activation property.
jwomeara Apr 16, 2021
1b7c9dd
Fixed activation profile syntax in bootstrap.yml
jwomeara May 18, 2021
6ae7fc7
Updated the audit service producer confirm ack configuration for spri…
jwomeara Aug 19, 2021
8267e44
Updated to use the revamped spring cloud stream binding mechanism.
jwomeara Sep 3, 2021
e407c7c
Added a default constructor for the Request class to enable proper (d…
jwomeara Sep 7, 2021
610a1c3
Updated hadoop version
ivakegg Oct 1, 2021
ade6340
Exclude jetty
ivakegg Oct 4, 2021
6c49bdd
Removed unnecessary annotation.
jwomeara Jan 4, 2022
54d124e
Updated datawave microservice parent version to 1.9-SNAPSHOT.
jwomeara Jan 27, 2022
cdec180
Removed Junit 4 and vintage junit.
cmitchell Apr 20, 2022
5fa8679
Removed Junit 4 and vintage junit.
cmitchell Apr 20, 2022
88d45a5
Merge branch 'master' into feature/queryMicroservices
ivakegg Apr 20, 2022
c3c38d5
Merge branch 'feature/queryMicroservices' of github.com:NationalSecur…
ivakegg Apr 20, 2022
6674c88
Use Spring's @Secured instead of javax.annotations @RolesAllowed.
cmitchell Apr 20, 2022
67f2799
Merge branch 'feature/queryMicroservices' of github.com:NationalSecur…
ivakegg Apr 21, 2022
d02250b
Updated hazelcast service version
ivakegg Apr 21, 2022
49ae461
Replaced javax.annotations.Resource with spring equivalent and replac…
cmitchell Apr 21, 2022
603d752
Re-configured multipleAuditReplayTest to avoid race condition.
cmitchell Apr 22, 2022
af4fa55
Merge branch 'feature/queryMicroservices' of github.com:NationalSecur…
ivakegg Apr 25, 2022
19cb0e8
Updated log audit tests to work with the latest version of spring-boot
jwomeara Apr 26, 2022
bc0e792
Revert "Replaced javax.annotations.Resource with spring equivalent an…
ivakegg Apr 26, 2022
d31bc38
Merge branch 'feature/queryMicroservices' of github.com:NationalSecur…
ivakegg Apr 26, 2022
ad61e35
Set relative path for full build
jwomeara May 12, 2022
38098f4
Added an activation property for the docker profile
jwomeara May 20, 2022
52f15e8
Avoid transient log4j imports via zookeeper
ivakegg Jun 10, 2022
c5418f3
Updated to use openapi 3
jwomeara Jun 10, 2022
ec251f7
cleaned up imports
jwomeara Jun 16, 2022
bb8b9b3
Updated swagger docs
jwomeara Jun 17, 2022
8889771
Updated spring boot to 2.7.1
jwomeara Jul 8, 2022
eef372f
Updated accumulo to 1.10.2
jwomeara Jul 11, 2022
aef8b44
Bumped hadoop to 3.3.3
jwomeara Sep 28, 2022
509b213
Updated to use microservice parent 2.0 and microservice service paren…
jwomeara Oct 17, 2022
ed44f45
Added curly braces to if statements
jwomeara Dec 2, 2022
be82cd8
Merge remote-tracking branch 'origin/feature/queryMicroservices' into…
jwomeara Dec 5, 2022
d06f5c4
Increased the timeout in the audit replay tests.
jwomeara Dec 15, 2022
64ad5ba
Updated audit tests to use common timeout value.
jwomeara Dec 15, 2022
c4abd22
Renamed ProxiedUserDetails as DatawaveUserDetails
jwomeara Dec 23, 2022
7161bb8
Increase the timeout for the audit replay tests
ivakegg Jan 20, 2023
080d7f1
Updated accumulo utils and datawave starter versions.
jwomeara Feb 10, 2023
e7d5dc3
Updated the audit api and audit starter versions
jwomeara Feb 10, 2023
966f882
Updated hazelcast version
jwomeara Feb 10, 2023
90f7fc9
Updated audit project version to 2.0-SNAPSHOT
jwomeara Mar 6, 2023
d2a3c2a
Merge branch 'main' into feature/spring-boot-2.x
jwomeara Mar 7, 2023
4a66834
Merge remote-tracking branch 'origin/release/accumulo-2.1' into featu…
jwomeara Mar 10, 2023
7524b04
pr feedback - static assertion imports
jwomeara Mar 11, 2023
680ef1f
Merge branch 'feature/spring-boot-2.x' into feature/spring-boot-2.x-a…
jwomeara Mar 11, 2023
5af9ff5
Merge remote-tracking branch 'origin/main' into feature/spring-boot-2…
jwomeara Mar 14, 2023
9055715
Switched to DateTimeFormatter
jwomeara Mar 17, 2023
b42fc52
pr feedback
jwomeara Mar 30, 2023
382c9b9
Merge remote-tracking branch 'origin/main' into feature/spring-boot-2…
jwomeara Mar 30, 2023
d319146
Updated audit replay test to use concurrent deque to avoid intermitte…
jwomeara May 10, 2023
6cc2e37
formatted code with impsort plugin.
jwomeara Jun 27, 2023
df86892
added skipServices profile
jwomeara Jun 28, 2023
d8db4d0
Updated accumulo
jwomeara Sep 20, 2023
78ccb89
bumped versions for some modules
jwomeara Oct 5, 2023
3b5a0a7
updated to use semver
jwomeara Oct 12, 2023
46da8a2
bumped dependencies to tagged releases
jwomeara Oct 12, 2023
02f657e
[maven-release-plugin] prepare release api-3.0.0
jwomeara Oct 12, 2023
d24d3e2
[maven-release-plugin] prepare for next development iteration
jwomeara Oct 12, 2023
009c0c9
bumped dependencies to tagged releases
jwomeara Oct 12, 2023
bf21c69
[maven-release-plugin] prepare release service-3.0.0
jwomeara Oct 12, 2023
170ae0c
[maven-release-plugin] prepare for next development iteration
jwomeara Oct 12, 2023
e3c3e32
bumped parent pom version
jwomeara Oct 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<parent>
<groupId>gov.nsa.datawave.microservice</groupId>
<artifactId>datawave-microservice-parent</artifactId>
<version>1.9</version>
<relativePath />
<version>2.1-SNAPSHOT</version>
<relativePath>../../../microservice-parent/pom.xml</relativePath>
</parent>
<artifactId>audit-api</artifactId>
<version>2.1.2-SNAPSHOT</version>
<version>3.0-SNAPSHOT</version>
<url>https://code.nsa.gov/datawave-audit-service</url>
<scm>
<connection>scm:git:https://github.com/NationalSecurityAgency/datawave-audit-service.git</connection>
Expand Down Expand Up @@ -57,6 +57,10 @@
<artifactId>*</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
<exclusion>
<artifactId>*</artifactId>
<groupId>log4j</groupId>
</exclusion>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
Expand Down Expand Up @@ -94,7 +98,7 @@
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package datawave.webservice.common.audit;

import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import datawave.webservice.common.audit.Auditor.AuditType;
import org.apache.accumulo.core.security.ColumnVisibility;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
Expand All @@ -9,15 +16,6 @@
import java.util.Map;
import java.util.UUID;

import com.google.common.base.Splitter;
import datawave.webservice.common.audit.Auditor.AuditType;

import org.apache.accumulo.core.security.ColumnVisibility;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;

import com.google.common.base.Preconditions;

import static java.nio.charset.StandardCharsets.UTF_8;

public class AuditParameters {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
import org.apache.accumulo.core.security.ColumnVisibility;
import org.junit.jupiter.api.Test;

import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<parent>
<groupId>gov.nsa.datawave.microservice</groupId>
<artifactId>datawave-microservice-parent</artifactId>
<version>1.9</version>
<relativePath />
<version>2.1-SNAPSHOT</version>
<relativePath>../../microservice-parent/pom.xml</relativePath>
</parent>
<artifactId>audit-service-parent</artifactId>
<version>2.1.2-SNAPSHOT</version>
<version>3.0-SNAPSHOT</version>
<packaging>pom</packaging>
<url>https://code.nsa.gov/datawave-audit-service</url>
<modules>
Expand Down
45 changes: 36 additions & 9 deletions service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<parent>
<groupId>gov.nsa.datawave.microservice</groupId>
<artifactId>datawave-microservice-service-parent</artifactId>
<version>2.1</version>
<relativePath />
<version>3.1-SNAPSHOT</version>
<relativePath>../../../microservice-service-parent/pom.xml</relativePath>
</parent>
<artifactId>audit-service</artifactId>
<version>2.1.2-SNAPSHOT</version>
<version>3.0-SNAPSHOT</version>
<description>DATAWAVE Auditing Microservice</description>
<url>https://code.nsa.gov/datawave-audit-service</url>
<scm>
Expand All @@ -20,9 +20,9 @@
<properties>
<version.commons>3.9</version.commons>
<version.hadoop>3.3.4</version.hadoop>
<version.microservice.audit-api>2.1.2-SNAPSHOT</version.microservice.audit-api>
<version.microservice.hazelcast-client>2.1.1</version.microservice.hazelcast-client>
<version.microservice.starter>2.1.1</version.microservice.starter>
<version.microservice.audit-api>3.0-SNAPSHOT</version.microservice.audit-api>
<version.microservice.hazelcast-client>3.0-SNAPSHOT</version.microservice.hazelcast-client>
<version.microservice.starter>3.0-SNAPSHOT</version.microservice.starter>
<version.zookeeper>3.8.0</version.zookeeper>
</properties>
<dependencyManagement>
Expand Down Expand Up @@ -76,6 +76,10 @@
<artifactId>*</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
<exclusion>
<artifactId>avro</artifactId>
<groupId>org.apache.avro</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand All @@ -87,6 +91,10 @@
<artifactId>*</artifactId>
<groupId>org.mortbay.jetty</groupId>
</exclusion>
<exclusion>
<artifactId>*</artifactId>
<groupId>org.eclipse.jetty</groupId>
</exclusion>
<exclusion>
<artifactId>*</artifactId>
<groupId>io.netty</groupId>
Expand All @@ -106,6 +114,14 @@
<artifactId>zookeeper</artifactId>
<version>${version.zookeeper}</version>
<exclusions>
<exclusion>
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
<exclusion>
<artifactId>log4j</artifactId>
<groupId>log4j</groupId>
</exclusion>
<exclusion>
<artifactId>*</artifactId>
<groupId>ch.qos.logback</groupId>
Expand Down Expand Up @@ -151,13 +167,19 @@
<artifactId>hadoop-hdfs</artifactId>
</dependency>
<dependency>
<groupId>gov.nsa.datawave.contrib</groupId>
<groupId>gov.nsa.datawave</groupId>
<artifactId>datawave-in-memory-accumulo</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-test-support</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -192,6 +214,11 @@
<profiles>
<profile>
<id>docker</id>
<activation>
<property>
<name>microservice-docker</name>
</property>
</activation>
<build>
<plugins>
<plugin>
Expand Down
115 changes: 94 additions & 21 deletions service/src/main/java/datawave/microservice/audit/AuditController.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
package datawave.microservice.audit;

import datawave.microservice.audit.common.AuditMessage;
import datawave.microservice.audit.common.AuditMessageSupplier;
import datawave.microservice.audit.config.AuditProperties;
import datawave.microservice.audit.config.AuditProperties.Retry;
import datawave.microservice.audit.config.AuditServiceConfig;
import datawave.microservice.audit.health.HealthChecker;
import datawave.webservice.common.audit.AuditParameters;
import datawave.webservice.common.audit.Auditor;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.ExternalDocumentation;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -20,21 +26,18 @@
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.security.access.annotation.Secured;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.security.RolesAllowed;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import static datawave.microservice.audit.config.AuditServiceConfig.CONFIRM_ACK_CHANNEL;
import static datawave.webservice.common.audit.AuditParameters.AUDIT_ID;
import static datawave.webservice.common.audit.AuditParameters.QUERY_AUDIT_TYPE;
import static datawave.webservice.common.audit.AuditParameters.QUERY_AUTHORIZATIONS;
Expand All @@ -53,16 +56,22 @@
* message passing infrastructure is unhealthy, or if we can't verify that the message was successfully passed to our messaging infrastructure, a 500 Internal
* Server Error will be returned to the caller.
*/
@Tag(name = "Audit Controller /v1", description = "DataWave Query Auditing",
externalDocs = @ExternalDocumentation(description = "Audit Service Documentation",
url = "https://github.com/NationalSecurityAgency/datawave-audit-service"))
@RestController
@RequestMapping(path = "/v1", produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(path = "/v1", produces = MediaType.TEXT_PLAIN_VALUE)
public class AuditController {
// Note: This must match 'confirmAckChannel' in the service configuration. Default set in bootstrap.yml.
public static final String CONFIRM_ACK_CHANNEL = "confirmAckChannel";

private final Logger log = LoggerFactory.getLogger(this.getClass());

private final AuditProperties auditProperties;

private final AuditParameters restAuditParams;

private final MessageChannel messageChannel;
private final AuditMessageSupplier auditSource;

@Autowired(required = false)
private HealthChecker healthChecker;
Expand All @@ -73,11 +82,10 @@ public class AuditController {

private static final Map<String,CountDownLatch> correlationLatchMap = new ConcurrentHashMap<>();

public AuditController(AuditProperties auditProperties, @Qualifier("restAuditParams") AuditParameters restAuditParams,
@Qualifier(AuditServiceConfig.AuditSourceBinding.NAME) MessageChannel messageChannel) {
public AuditController(AuditProperties auditProperties, @Qualifier("restAuditParams") AuditParameters restAuditParams, AuditMessageSupplier auditSource) {
this.auditProperties = auditProperties;
this.restAuditParams = restAuditParams;
this.messageChannel = messageChannel;
this.auditSource = auditSource;
}

/**
Expand Down Expand Up @@ -121,7 +129,7 @@ private boolean sendMessage(AuditParameters parameters) {
correlationLatchMap.put(auditId, latch);
}

boolean success = messageChannel.send(MessageBuilder.withPayload(AuditMessage.fromParams(parameters)).setCorrelationId(auditId).build());
boolean success = auditSource.send(MessageBuilder.withPayload(AuditMessage.fromParams(parameters)).setCorrelationId(auditId).build());

if (auditProperties.isConfirmAckEnabled()) {
try {
Expand All @@ -146,14 +154,79 @@ private boolean sendMessage(AuditParameters parameters) {
* the audit parameters
* @return an audit ID, which can be used for tracking purposes
*/
@ApiOperation(value = "Performs auditing for the given parameters.")
@ApiImplicitParams({@ApiImplicitParam(name = USER_DN, required = true), @ApiImplicitParam(name = QUERY_STRING, required = true),
@ApiImplicitParam(name = QUERY_SELECTORS), @ApiImplicitParam(name = QUERY_AUTHORIZATIONS, required = true),
@ApiImplicitParam(name = QUERY_AUDIT_TYPE, required = true), @ApiImplicitParam(name = QUERY_SECURITY_MARKING_COLVIZ, required = true),
@ApiImplicitParam(name = QUERY_DATE), @ApiImplicitParam(name = QUERY_LOGIC_CLASS), @ApiImplicitParam(name = AUDIT_ID)})
@RolesAllowed({"AuthorizedUser", "AuthorizedServer", "InternalUser", "Administrator"})
// @formatter:off
@Operation(
summary = "Submit an audit message with the given parameters.",
description = "Audit messages will be forwarded to the configured auditors.")
@ApiResponse(
description = "if successful, returns the audit ID",
responseCode = "200",
content = @Content(schema = @Schema(implementation = String.class))
)
@Parameters({
@Parameter(
name = USER_DN,
in = ParameterIn.QUERY,
description = "The user's DN",
required = true,
schema = @Schema(implementation = String.class),
example = "cn=test a. user, ou=example developers, o=example corp, c=us<cn=example corp ca, o=example corp, c=us>"),
@Parameter(
name = QUERY_STRING,
in = ParameterIn.QUERY,
description = "The user-specified query",
required = true,
schema = @Schema(implementation = String.class),
example = "GENRES:[Action to Western]"),
@Parameter(
name = QUERY_SELECTORS,
in = ParameterIn.QUERY,
description = "The selectors present in the query",
schema = @Schema(implementation = String.class),
example = "A,E,I,O,U"),
@Parameter(
name = QUERY_AUTHORIZATIONS,
in = ParameterIn.QUERY,
description = "The user-selected authorizations",
required = true,
schema = @Schema(implementation = String.class),
example = "PUBLIC,PRIVATE,BAR,FOO"),
@Parameter(
name = QUERY_AUDIT_TYPE,
in = ParameterIn.QUERY,
description = "The audit type",
required = true,
schema = @Schema(implementation = String.class),
example = "ACTIVE"),
@Parameter(
name = QUERY_SECURITY_MARKING_COLVIZ,
in = ParameterIn.QUERY,
description = "The visibility to use when storing the audit record",
required = true,
schema = @Schema(implementation = String.class),
example = "PUBLIC"),
@Parameter(
name = QUERY_DATE,
in = ParameterIn.QUERY,
description = "The date the user ran the query",
schema = @Schema(implementation = Long.class),
example = "1655410818951"),
@Parameter(
name = QUERY_LOGIC_CLASS,
in = ParameterIn.QUERY,
description = "The query logic used",
schema = @Schema(implementation = String.class),
example = "EventQuery"),
@Parameter(
name = AUDIT_ID,
in = ParameterIn.QUERY,
description = "An optional audit ID to use for tracking purposes",
schema = @Schema(implementation = String.class),
example = "my-audit-id")})
// @formatter:on
@Secured({"AuthorizedUser", "AuthorizedServer", "InternalUser", "Administrator"})
@RequestMapping(path = "/audit", method = RequestMethod.POST)
public String audit(@RequestParam MultiValueMap<String,String> parameters) {
public String audit(@Parameter(hidden = true) @RequestParam MultiValueMap<String,String> parameters) {
restAuditParams.clear();
restAuditParams.validate(parameters);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package datawave.microservice.audit;

import datawave.microservice.audit.config.AuditServiceConfig;
import datawave.webservice.common.audit.AuditParameters;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.context.annotation.Bean;
import org.springframework.web.context.annotation.RequestScope;

Expand All @@ -15,7 +13,6 @@
*/
@EnableDiscoveryClient
@SpringBootApplication(scanBasePackages = "datawave.microservice", exclude = {ErrorMvcAutoConfiguration.class})
@EnableBinding(AuditServiceConfig.AuditSourceBinding.class)
public class AuditService {

@Bean("restAuditParams")
Expand Down
Loading