Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 22 additions & 0 deletions .github/workflows/pic-sure-logging-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: pic-sure-logging tests
on:
pull_request:
paths: ['services/pic-sure-logging/**']
push:
branches: [main]
paths: ['services/pic-sure-logging/**']
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
- name: Set up JDK 25
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 #v5.2.0
with:
java-version: '25'
distribution: 'temurin'
cache: maven
- name: Test with Maven
run: mvn -B -pl services/pic-sure-logging -am verify
env:
GITHUB_TOKEN: ${{ github.token }}
7 changes: 7 additions & 0 deletions platform/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
<wiremock.version>3.10.0</wiremock.version>
<!-- HTTP-client winner (consolidation Phase 4) — aligned with spring-boot-dependencies -->
<httpclient5.version>5.5.2</httpclient5.version>
<!-- Structured logging encoder (not governed by the Spring BOMs) -->
<logstash-logback-encoder.version>8.1</logstash-logback-encoder.version>
</properties>
<dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -92,6 +94,11 @@
<artifactId>httpclient5</artifactId>
<version>${httpclient5.version}</version>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>${logstash-logback-encoder.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<distributionManagement>
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<module>services/picsure-dictionary</module>
<module>services/picsure-dictionary/aggregate</module>
<module>services/picsure-dictionary/dictionaryweights</module>
<module>services/pic-sure-logging</module>
<!-- pic-sure-legacy is deliberately NOT aggregated: it is quarantined
(Java 11/javax, own parent pom) and builds independently. -->
</modules>
Expand Down
2 changes: 1 addition & 1 deletion services/pic-sure-logging/.sdkmanrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
java=21.0.10-tem
java=25.0.3-tem
6 changes: 3 additions & 3 deletions services/pic-sure-logging/jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ pipeline {
docker run --rm \
-v "$MOUNT_PATH/:/app:Z" \
-v maven_m2_cache:/root/.m2 \
-w /app \
-w /app/services/pic-sure-logging \
maven:3.9.9-amazoncorretto-24 \
sh -lc "mvn clean install -B -T 1C -DskipTests"

ls -lah target || true
ls -lah services/pic-sure-logging/target || true
'''
}
}
Expand All @@ -62,7 +62,7 @@ pipeline {
PROXY_ARGS="$PROXY_ARGS --build-arg no_proxy=$no_proxy --build-arg NO_PROXY=$no_proxy"
fi

docker build --load $PROXY_ARGS -t "${IMAGE_NAME}:${IMAGE_TAG}" .
docker build --load $PROXY_ARGS -t "${IMAGE_NAME}:${IMAGE_TAG}" services/pic-sure-logging
docker tag "${IMAGE_NAME}:${IMAGE_TAG}" "${IMAGE_NAME}:${LATEST_TAG}"
'''
}
Expand Down
49 changes: 25 additions & 24 deletions services/pic-sure-logging/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,40 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>edu.harvard.hms.dbmi.avillach</groupId>
<artifactId>pic-sure-api</artifactId>
<version>${revision}</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<groupId>edu.harvard.dbmi.avillach</groupId>
<artifactId>pic-sure-logging</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>PIC-SURE Audit Logging Service</name>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Stays Javalin (the one non-Spring service, spec §17.3); Javalin is not BOM-governed. -->
<javalin.version>6.7.0</javalin.version>
<jackson.version>2.17.2</jackson.version>
<java-jwt.version>4.4.0</java-jwt.version>
<slf4j.version>2.0.17</slf4j.version>
<logback.version>1.5.29</logback.version>
<logstash-logback-encoder.version>8.1</logstash-logback-encoder.version>
<junit.version>5.10.3</junit.version>
<mockito.version>5.14.2</mockito.version>
</properties>

<dependencyManagement>
<dependencies>
<!-- Javalin 6.x embeds Jetty 11; without this import the platform BOM's Jetty 12
pins win over Javalin's transitives (NoSuchMethodError at server start).
A module's own dependencyManagement outranks the inherited one. -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-bom</artifactId>
<version>11.0.25</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<!-- HTTP Server -->
<dependency>
Expand All @@ -33,11 +45,10 @@
<version>${javalin.version}</version>
</dependency>

<!-- JSON -->
<!-- JSON (BOM-managed) -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>

<!-- JWT -->
Expand All @@ -47,34 +58,29 @@
<version>${java-jwt.version}</version>
</dependency>

<!-- Logging -->
<!-- Logging (BOM-managed) -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>${logstash-logback-encoder.version}</version>
</dependency>

<!-- Testing -->
<!-- Testing (BOM-managed) -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -118,11 +124,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ public static void main(String[] args) {
app.stop();
}));

log.info("Audit logging service started: app={}, platform={}, environment={}, hostname={}, port={}, allowedOrigin={}",
config.app(), config.platform(), config.environment(), config.hostname(), config.port(), config.allowedOrigin());
log.info(
"Audit logging service started: app={}, platform={}, environment={}, hostname={}, port={}, allowedOrigin={}", config.app(),
config.platform(), config.environment(), config.hostname(), config.port(), config.allowedOrigin()
);
}

public static Javalin createApp(AppConfig config, AtomicBoolean readiness) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,16 @@
import java.util.function.Function;

public record AppConfig(
String auditApiKey,
String app,
String platform,
String environment,
String hostname,
int port,
String allowedOrigin,
String auditApiKey, String app, String platform, String environment, String hostname, int port, String allowedOrigin,
Map<String, String> jwtClaimMapping
) {

private static final Map<String, String> DEFAULT_JWT_CLAIM_MAPPING = Map.ofEntries(
Map.entry("sub", "subject"),
Map.entry("email", "user_email"),
Map.entry("name", "user_name"),
Map.entry("userid", "user_id"),
Map.entry("preferred_username", "preferred_username"),
Map.entry("org", "user_org"),
Map.entry("country_name", "user_country_name"),
Map.entry("nih_ico", "nih_ico"),
Map.entry("eRA_commons_id", "eRA_commons_id"),
Map.entry("user_permission_group", "user_permission_group"),
Map.entry("uuid", "uuid"),
Map.entry("roles", "roles"),
Map.entry("idp", "user_id_provider"),
Map.entry("cadr_name", "cadr_name")
Map.entry("sub", "subject"), Map.entry("email", "user_email"), Map.entry("name", "user_name"), Map.entry("userid", "user_id"),
Map.entry("preferred_username", "preferred_username"), Map.entry("org", "user_org"), Map.entry("country_name", "user_country_name"),
Map.entry("nih_ico", "nih_ico"), Map.entry("eRA_commons_id", "eRA_commons_id"),
Map.entry("user_permission_group", "user_permission_group"), Map.entry("uuid", "uuid"), Map.entry("roles", "roles"),
Map.entry("idp", "user_id_provider"), Map.entry("cadr_name", "cadr_name")
);

public static AppConfig fromEnvironment() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ public AuditHandler(AuditLogService auditLogService) {
this.auditLogService = auditLogService;
this.objectMapper = new ObjectMapper();
objectMapper.getFactory().setStreamReadConstraints(
StreamReadConstraints.builder()
.maxNestingDepth(10)
.maxStringLength(10_240) // 10KB
StreamReadConstraints.builder().maxNestingDepth(10).maxStringLength(10_240) // 10KB
.build()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ public class InfoHandler {
private final InfoResponse response;

public InfoHandler() {
this.response = new InfoResponse(
UUID.nameUUIDFromBytes(":)".getBytes()),
"Logging Service",
List.of()
);
this.response = new InfoResponse(UUID.nameUUIDFromBytes(":)".getBytes()), "Logging Service", List.of());
}

public void handle(Context ctx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,8 @@

@JsonIgnoreProperties(ignoreUnknown = true)
public record AuditEvent(
@JsonProperty("event_type") String eventType,
@JsonProperty("action") String action,
@JsonProperty("client_type") String clientType,
@JsonProperty("caller") String caller,
@JsonProperty("session_id") String sessionId,
@JsonProperty("request") RequestInfo request,
@JsonProperty("metadata") Map<String, Object> metadata,
@JsonProperty("error") Map<String, Object> error
@JsonProperty("event_type") String eventType, @JsonProperty("action") String action, @JsonProperty("client_type") String clientType,
@JsonProperty("caller") String caller, @JsonProperty("session_id") String sessionId, @JsonProperty("request") RequestInfo request,
@JsonProperty("metadata") Map<String, Object> metadata, @JsonProperty("error") Map<String, Object> error
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,10 @@

@JsonIgnoreProperties(ignoreUnknown = true)
public record RequestInfo(
@JsonProperty("request_id") String requestId,
@JsonProperty("method") String method,
@JsonProperty("url") String url,
@JsonProperty("query_string") String queryString,
@JsonProperty("src_ip") String srcIp,
@JsonProperty("dest_ip") String destIp,
@JsonProperty("dest_port") Integer destPort,
@JsonProperty("http_user_agent") String httpUserAgent,
@JsonProperty("http_content_type") String httpContentType,
@JsonProperty("status") Integer status,
@JsonProperty("bytes") Long bytes,
@JsonProperty("duration") Long duration,
@JsonProperty("referrer") String referrer
) {}
@JsonProperty("request_id") String requestId, @JsonProperty("method") String method, @JsonProperty("url") String url,
@JsonProperty("query_string") String queryString, @JsonProperty("src_ip") String srcIp, @JsonProperty("dest_ip") String destIp,
@JsonProperty("dest_port") Integer destPort, @JsonProperty("http_user_agent") String httpUserAgent,
@JsonProperty("http_content_type") String httpContentType, @JsonProperty("status") Integer status, @JsonProperty("bytes") Long bytes,
@JsonProperty("duration") Long duration, @JsonProperty("referrer") String referrer
) {
}
Loading
Loading