Skip to content

Commit a40dfda

Browse files
authored
feat: major refactor
* feat: @slf4j annotated logs * feat: remove unused Example controller * feat: add visibility default value for API compliance * feat: remove multiple plateform handling, remove unused endpoints * fix: remove unused log, add log for handling file errors * chore: move constants where they're needed, explicit type for xsl transformations * chore: massive refactor 😉 * fix: expose TrainingScenario label and type, fix path traversal attack * chore: keycloak -> oidc migration, spring 5 -> 6 * chore: handle authentication via Interceptor, rename properties, add CORS * ci: fix release creation
1 parent 975f1a5 commit a40dfda

File tree

129 files changed

+2431
-19802
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+2431
-19802
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,14 @@ jobs:
3535
run: echo "::set-output name=prop::$(mvn -f pom.xml help:evaluate -Dexpression=project.version -q -DforceStdout)"
3636
- run: echo ${{steps.version.outputs.prop}}
3737
- name: Release snapshot
38-
id: release_snapshot
39-
uses: actions/create-release@v4
40-
env:
41-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
uses: softprops/action-gh-release@v1
4239
with:
43-
tag_name: ${{steps.version.outputs.prop}}
44-
release_name: Release ${{steps.version.outputs.prop}}
40+
tag_name: ${{ steps.version.outputs.prop }}
41+
name: Release ${{ steps.version.outputs.prop }}
4542
draft: false
4643
prerelease: false
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4746
docker:
4847
needs: build
4948
runs-on: ubuntu-latest

Dockerfile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1-
FROM tomcat:8.5-jdk11-slim
1+
FROM tomcat:9-jre17-temurin
22

3-
RUN rm -rf $CATALINA_HOME/webapps/*
3+
# Create a non-root user and group
4+
5+
RUN rm -rf "$CATALINA_HOME"/webapps/*
46
COPY sabdatab.properties log4j2.xml $CATALINA_HOME/webapps/
5-
ADD /target/*.war $CATALINA_HOME/webapps/ROOT.war
7+
COPY target/*.war $CATALINA_HOME/webapps/ROOT.war
8+
9+
# Setup a non-root user context (security)
10+
RUN addgroup -g 1000 tomcatgroup; \
11+
adduser -D -s / -u 1000 tomcatuser -G tomcatgroup; \
12+
chown -R tomcat:tomcat "$CATALINA_HOME"
13+
14+
USER 1000
15+
16+
# Start Tomcat
17+
CMD ["catalina.sh", "run"]

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ To override environments variables you can do :
1717

1818
### With Maven - Requirements
1919
For building and running the application you need:
20-
- [JDK 11](https://jdk.java.net/archive/)
20+
- [JDK 17](https://adoptium.net/fr/temurin/releases/?version=17)
2121
- Maven 3
2222

2323
### With Maven - Install and execute unit tests
@@ -33,31 +33,32 @@ mvn spring-boot:run
3333
```
3434

3535
## Application Accesses locally
36-
To access to swagger-ui, use this url : [http://localhost:8080/api/swagger-ui.html](http://localhost:8080/api/swagger-ui.html)
36+
To access to swagger-ui, use this url : [http://localhost:8080/api/swagger-ui.html](http://localhost:8080/)
3737

3838
## Deploy application on Tomcat server
3939
### 1. Package the application
4040
Use the [Spring Boot Maven plugin] (https://docs.spring.io/spring-boot/docs/current/reference/html/build-tool-plugins-maven-plugin.html) like so:
4141
```shell
4242
mvn clean package
4343
```
44-
The war will be generate in `/target` repository
44+
The war will be generated in `/target` repository
4545

4646
### 2. Install tomcat and deploy war
4747
To deploy the war file in Tomcat, you need to :
4848
Download Apache Tomcat and unpackage it into a tomcat folder
4949
Copy your WAR file from target/ to the tomcat/webapps/ folder
5050

5151
### 3. Tomcat config
52-
Before to startup the tomcat server, some configurations are needed :
52+
Before starting up the tomcat server, some configurations are needed :
5353

5454

5555
#### External Properties file
56+
!!! => To be migrated to embedded Tomcat and env-var configuration
5657
Create sabdatab.properties near war file and complete the following properties:
57-
```shell
58+
```properties
5859
#Profile configuration
5960

60-
# Security : "keycloak" or "none"
61+
# Security : "keycloak" for keycloak impl, anything else => no auth
6162
fr.insee.sabianedata.security=none
6263

6364
############# Swagger host #############

pom.xml

Lines changed: 29 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,32 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0"
2-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
44
<modelVersion>4.0.0</modelVersion>
55

6+
7+
<parent>
8+
<groupId>org.springframework.boot</groupId>
9+
<artifactId>spring-boot-starter-parent</artifactId>
10+
<version>3.4.4</version>
11+
<relativePath/> <!-- Use default parent from central repo -->
12+
</parent>
13+
614
<groupId>fr.insee</groupId>
715
<artifactId>sabdatab</artifactId>
816
<packaging>war</packaging>
9-
<version>3.0.7</version>
17+
<version>4.0.0</version>
1018
<name>Sabiane Data</name>
1119

1220
<properties>
13-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14-
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
1521
<java.version>17</java.version>
16-
<maven.compiler.source>${java.version}</maven.compiler.source>
17-
<maven.compiler.target>${java.version}</maven.compiler.target>
18-
<failOnMissingWebXml>false</failOnMissingWebXml>
19-
2022
<final.war.name>sabdatab</final.war.name>
21-
<javax.activation.version>1.2.0</javax.activation.version>
22-
<jaxb.api.version>2.3.0</jaxb.api.version>
23-
<springdoc-openapi-ui.version>1.5.5</springdoc-openapi-ui.version>
24-
<saxon.version>10.6</saxon.version>
25-
<xalan.version>2.7.3</xalan.version>
26-
<commons-io.version>2.11.0</commons-io.version>
27-
<log4j2.version>2.17.1</log4j2.version>
28-
<spring-boot-dependencies.version>2.6.6</spring-boot-dependencies.version>
29-
23+
<springdoc-openapi-ui.version>1.7.0</springdoc-openapi-ui.version>
24+
<saxon.version>12.5</saxon.version>
25+
<commons-io.version>2.18.0</commons-io.version>
26+
<log4j2.version>2.22.1</log4j2.version>
27+
<keycloak.version>21.1.1</keycloak.version>
3028
</properties>
3129

32-
<repositories>
33-
<repository>
34-
<id>maven2-repository.java.net</id>
35-
<name>Java.net Repository for Maven</name>
36-
<url>https://maven.java.net/content/groups/public/</url>
37-
<layout>default</layout>
38-
</repository>
39-
<repository>
40-
<id>repository.spring.release</id>
41-
<name>Spring GA Repository</name>
42-
<url>http://repo.spring.io/release</url>
43-
</repository>
44-
</repositories>
4530

4631
<dependencies>
4732
<!-- spring-web -->
@@ -55,49 +40,34 @@
5540
<artifactId>spring-boot-starter-security</artifactId>
5641
</dependency>
5742

58-
5943
<!-- swagger -->
6044
<dependency>
6145
<groupId>org.springdoc</groupId>
62-
<artifactId>springdoc-openapi-ui</artifactId>
63-
<version>${springdoc-openapi-ui.version}</version>
46+
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
47+
<version>2.8.6</version>
6448
</dependency>
6549

6650
<dependency>
67-
<groupId>org.keycloak</groupId>
68-
<artifactId>keycloak-spring-boot-starter</artifactId>
51+
<groupId>org.springframework.boot</groupId>
52+
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
6953
</dependency>
54+
7055
<dependency>
7156
<groupId>net.sf.saxon</groupId>
7257
<artifactId>Saxon-HE</artifactId>
7358
<version>${saxon.version}</version>
7459
</dependency>
75-
<dependency>
76-
<groupId>xalan</groupId>
77-
<artifactId>xalan</artifactId>
78-
<version>${xalan.version}</version>
79-
</dependency>
8060

81-
<dependency>
82-
<groupId>com.fasterxml.jackson.module</groupId>
83-
<artifactId>jackson-module-jaxb-annotations</artifactId>
84-
</dependency>
8561
<dependency>
8662
<groupId>com.fasterxml.jackson.dataformat</groupId>
8763
<artifactId>jackson-dataformat-xml</artifactId>
8864
</dependency>
8965

90-
<dependency>
91-
<groupId>com.googlecode.json-simple</groupId>
92-
<artifactId>json-simple</artifactId>
93-
<version>1.1.1</version>
94-
</dependency>
95-
9666
<!-- Lombok -->
9767
<dependency>
9868
<groupId>org.projectlombok</groupId>
9969
<artifactId>lombok</artifactId>
100-
<version>1.18.32</version>
70+
<version>1.18.36</version>
10171
<optional>true</optional>
10272
</dependency>
10373

@@ -124,119 +94,14 @@
12494
</dependency>
12595

12696
<dependency>
127-
<groupId>com.sun.activation</groupId>
128-
<artifactId>javax.activation</artifactId>
129-
<version>${javax.activation.version}</version>
130-
</dependency>
131-
132-
<dependency>
133-
<groupId>javax.xml.bind</groupId>
134-
<artifactId>jaxb-api</artifactId>
135-
<version>${jaxb.api.version}</version>
136-
</dependency>
137-
138-
<dependency>
139-
<groupId>com.sun.xml.bind</groupId>
140-
<artifactId>jaxb-core</artifactId>
141-
<version>${jaxb.api.version}</version>
142-
</dependency>
143-
144-
<dependency>
145-
<groupId>com.sun.xml.bind</groupId>
146-
<artifactId>jaxb-impl</artifactId>
147-
<version>${jaxb.api.version}</version>
148-
</dependency>
149-
150-
<!-- test -->
151-
<dependency>
152-
<groupId>org.apache.httpcomponents</groupId>
153-
<artifactId>httpclient</artifactId>
154-
</dependency>
155-
156-
<dependency>
157-
<groupId>org.apache.httpcomponents</groupId>
158-
<artifactId>httpmime</artifactId>
159-
</dependency>
160-
<dependency>
161-
<groupId>org.springframework.boot</groupId>
162-
<artifactId>spring-boot-starter-test</artifactId>
163-
<scope>test</scope>
164-
</dependency>
165-
<dependency>
166-
<groupId>org.springframework</groupId>
167-
<artifactId>spring-test</artifactId>
168-
<scope>test</scope>
169-
</dependency>
170-
171-
<dependency>
172-
<groupId>org.springframework.boot</groupId>
173-
<artifactId>spring-boot-test-autoconfigure</artifactId>
174-
<scope>test</scope>
97+
<groupId>jakarta.servlet</groupId>
98+
<artifactId>jakarta.servlet-api</artifactId>
99+
<version>6.1.0</version>
100+
<scope>provided</scope>
175101
</dependency>
176102

177-
<dependency>
178-
<groupId>org.springframework.boot</groupId>
179-
<artifactId>spring-boot-starter-actuator</artifactId>
180-
</dependency>
181-
182-
183-
<dependency>
184-
<groupId>junit</groupId>
185-
<artifactId>junit</artifactId>
186-
<scope>test</scope>
187-
</dependency>
188-
189-
<!-- Prometheus Metrics -->
190-
<dependency>
191-
<groupId>io.micrometer</groupId>
192-
<artifactId>micrometer-registry-prometheus</artifactId>
193-
<version>1.7.0</version>
194-
</dependency>
195103
</dependencies>
196104

197-
<dependencyManagement>
198-
<dependencies>
199-
200-
<dependency>
201-
<groupId>org.keycloak.bom</groupId>
202-
<artifactId>keycloak-adapter-bom</artifactId>
203-
<version>15.0.2</version>
204-
<type>pom</type>
205-
<scope>import</scope>
206-
</dependency>
207-
<!-- permet de garder l'héritage des versions springboot sans dépendre
208-
du parent -->
209-
<dependency>
210-
<groupId>org.springframework.boot</groupId>
211-
<artifactId>spring-boot-dependencies</artifactId>
212-
<version>${spring-boot-dependencies.version}</version>
213-
<type>pom</type>
214-
<scope>import</scope>
215-
</dependency>
216-
<dependency>
217-
<groupId>org.apache.logging.log4j</groupId>
218-
<artifactId>log4j-api</artifactId>
219-
<version>${log4j2.version}</version>
220-
</dependency>
221-
<dependency>
222-
<groupId>org.apache.logging.log4j</groupId>
223-
<artifactId>log4j-core</artifactId>
224-
<version>${log4j2.version}</version>
225-
</dependency>
226-
<dependency>
227-
<groupId>org.apache.logging.log4j</groupId>
228-
<artifactId>log4j-jul</artifactId>
229-
<version>${log4j2.version}</version>
230-
</dependency>
231-
<dependency>
232-
<groupId>org.apache.logging.log4j</groupId>
233-
<artifactId>log4j-slf4j-impl</artifactId>
234-
<version>${log4j2.version}</version>
235-
</dependency>
236-
</dependencies>
237-
</dependencyManagement>
238-
239-
240105
<build>
241106
<finalName>${final.war.name}</finalName>
242107
<resources>
@@ -266,7 +131,6 @@
266131
<plugin>
267132
<groupId>org.springframework.boot</groupId>
268133
<artifactId>spring-boot-maven-plugin</artifactId>
269-
<version>${spring-boot-dependencies.version}</version>
270134
<executions>
271135
<execution>
272136
<id>repackage</id>
@@ -275,10 +139,9 @@
275139
</goals>
276140
</execution>
277141
<execution>
278-
<id>conf</id>
279-
<configuration>
280-
<mainClass>fr.insee.sabianedata.ws.AppWS</mainClass>
281-
</configuration>
142+
<goals>
143+
<goal>build-info</goal>
144+
</goals>
282145
</execution>
283146
</executions>
284147
</plugin>

0 commit comments

Comments
 (0)