Skip to content
Merged
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
51 changes: 33 additions & 18 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,22 @@ specific language governing permissions and limitations
under the License.

This project includes:
Apache Commons Lang under Apache License, Version 2.0
Apache Log4j API under Apache License, Version 2.0
Apache Log4j to SLF4J Adapter under Apache License, Version 2.0
Apache Commons Lang under Apache-2.0
Apache Commons Logging under Apache-2.0
Apache Log4j API under Apache-2.0
asm under BSD-3-Clause
ASM based accessors helper used by json-smart under The Apache Software License, Version 2.0
AssertJ fluent assertions under Apache License, Version 2.0
AssertJ Core under Apache-2.0
Awaitility under Apache 2.0
Bouncy Castle Provider under Bouncy Castle Licence
Byte Buddy (without dependencies) under Apache License, Version 2.0
Byte Buddy agent under Apache License, Version 2.0
Hamcrest under BSD License 3
Hamcrest under BSD-3-Clause
hazelcast under The Apache Software License, Version 2.0
Jackson datatype: jdk8 under The Apache Software License, Version 2.0
Jackson datatype: JSR310 under The Apache Software License, Version 2.0
Jackson-annotations under The Apache Software License, Version 2.0
Jackson-core under The Apache Software License, Version 2.0
jackson-databind under The Apache Software License, Version 2.0
Jackson-module-parameter-names under The Apache Software License, Version 2.0
Jakarta Activation API jar under EDL 1.0
Jakarta Activation API under EDL 1.0
Jakarta Annotations API under EPL 2.0 or GPL2 w/ CPE
Jakarta XML Binding API under Eclipse Distribution License - v 1.0
JASYPT: Java Simplified Encryption under The Apache Software License, Version 2.0
Expand All @@ -43,31 +41,35 @@ This project includes:
JJWT :: Impl under Apache License, Version 2.0
JSON library from Android SDK under Apache License 2.0
JSON Small and Fast Parser under The Apache Software License, Version 2.0
json-path under The Apache Software License, Version 2.0
JSONassert under The Apache Software License, Version 2.0
JSpecify annotations under The Apache License, Version 2.0
JSR107 API and SPI under Apache License, Version 2.0
JUL to SLF4J bridge under MIT License
JUL to SLF4J bridge under MIT
JUnit Jupiter (Aggregator) under Eclipse Public License v2.0
JUnit Jupiter API under Eclipse Public License v2.0
JUnit Jupiter Engine under Eclipse Public License v2.0
JUnit Jupiter Params under Eclipse Public License v2.0
JUnit Platform Commons under Eclipse Public License v2.0
JUnit Platform Engine API under Eclipse Public License v2.0
Logback Classic Module under Eclipse Public License - v 1.0 or GNU Lesser General Public License
Logback Core Module under Eclipse Public License - v 1.0 or GNU Lesser General Public License
mockito-core under The MIT License
mockito-junit-jupiter under The MIT License
Log4j API to SLF4J Adapter under Apache-2.0
Logback Classic Module under EPL-2.0 or LGPL-2.1-only
Logback Core Module under EPL-2.0 or LGPL-2.1-only
micrometer-commons under The Apache Software License, Version 2.0
micrometer-observation under The Apache Software License, Version 2.0
mockito-core under MIT
mockito-junit-jupiter under MIT
Objenesis under Apache License, Version 2.0
org.apiguardian:apiguardian-api under The Apache License, Version 2.0
org.opentest4j:opentest4j under The Apache License, Version 2.0
org.xmlunit:xmlunit-core under The Apache Software License, Version 2.0
project ':json-path' under The Apache Software License, Version 2.0
Project Lombok under The MIT License
Ressources Diffusables API under Apache License, Version 2.0
SLF4J API Module under MIT License
SLF4J API Module under MIT
SnakeYAML under Apache License, Version 2.0
soffit-java-client under Apache License, Version 2.0
Spring AOP under Apache License, Version 2.0
Spring Beans under Apache License, Version 2.0
Spring Commons Logging Bridge under Apache License, Version 2.0
Spring Context under Apache License, Version 2.0
Spring Core under Apache License, Version 2.0
Spring Expression Language (SpEL) under Apache License, Version 2.0
Expand All @@ -77,15 +79,28 @@ This project includes:
spring-boot under Apache License, Version 2.0
spring-boot-autoconfigure under Apache License, Version 2.0
spring-boot-configuration-processor under Apache License, Version 2.0
spring-boot-http-converter under Apache License, Version 2.0
spring-boot-jackson under Apache License, Version 2.0
spring-boot-resttestclient under Apache License, Version 2.0
spring-boot-security under Apache License, Version 2.0
spring-boot-servlet under Apache License, Version 2.0
spring-boot-starter under Apache License, Version 2.0
spring-boot-starter-json under Apache License, Version 2.0
spring-boot-starter-jackson under Apache License, Version 2.0
spring-boot-starter-jackson-test under Apache License, Version 2.0
spring-boot-starter-logging under Apache License, Version 2.0
spring-boot-starter-security under Apache License, Version 2.0
spring-boot-starter-test under Apache License, Version 2.0
spring-boot-starter-tomcat under Apache License, Version 2.0
spring-boot-starter-tomcat-runtime under Apache License, Version 2.0
spring-boot-starter-web under Apache License, Version 2.0
spring-boot-starter-webmvc under Apache License, Version 2.0
spring-boot-starter-webmvc-test under Apache License, Version 2.0
spring-boot-test under Apache License, Version 2.0
spring-boot-test-autoconfigure under Apache License, Version 2.0
spring-boot-tomcat under Apache License, Version 2.0
spring-boot-web-server under Apache License, Version 2.0
spring-boot-webmvc under Apache License, Version 2.0
spring-boot-webmvc-test under Apache License, Version 2.0
spring-security-config under Apache License, Version 2.0
spring-security-core under Apache License, Version 2.0
spring-security-crypto under Apache License, Version 2.0
Expand Down
6 changes: 6 additions & 0 deletions etc/license-mappings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@
<license-lookup xmlns="https://source.jasig.org/schemas/maven-notice-plugin/license-lookup"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://source.jasig.org/schemas/maven-notice-plugin/license-lookup https://source.jasig.org/schemas/maven-notice-plugin/license-lookup/license-lookup-v1.0.xsd">
<artifact>
<groupId>fr.recia.notifications</groupId>
<artifactId>soffit-java-client</artifactId>
<version>0.0.2</version>
<license>Apache License, Version 2.0</license>
</artifact>
</license-lookup>
49 changes: 43 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.18</version>
<version>4.1.0</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

Expand All @@ -18,8 +18,8 @@
<description>API des ressources diffusables</description>

<properties>
<check.java.version>11</check.java.version>
<java.version>11</java.version>
<java.version>25</java.version>
<lombok.version>1.18.42</lombok.version>
</properties>

<dependencies>
Expand All @@ -35,6 +35,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<optional>true</optional>
</dependency>
<dependency>
Expand Down Expand Up @@ -71,12 +72,19 @@

<!-- == DatatypeConverter (Lire les JWT) == -->
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.1</version>
<groupId>fr.recia.notifications</groupId>
<artifactId>soffit-java-client</artifactId>
<version>0.0.2</version>
</dependency>
<!-- == §§ == -->


<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc-test</artifactId>
<scope>test</scope>
</dependency>

<!-- == Annotation Processor (Configurations application.yml additionnelles) == -->
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -86,6 +94,20 @@
<!-- == §§ == -->
</dependencies>

<repositories>
<repository>
<id>recia</id>
<url>https://nexus.recia.dev/repository/public/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>

<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -138,6 +160,21 @@
<attachClasses>true</attachClasses>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
<configuration>
<release>25</release>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;

@SpringBootApplication
@ConfigurationPropertiesScan
public class ApiMediacentreApplication {
public static void main(String[] args) {
SpringApplication.run(ApiMediacentreApplication.class, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
package fr.recia.ressourcesdiffusablesapi.config;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.hazelcast.shaded.com.fasterxml.jackson.core.JsonProcessingException;
import fr.recia.ressourcesdiffusablesapi.config.beans.CacheProperties;
import fr.recia.ressourcesdiffusablesapi.config.beans.CorsProperties;
import fr.recia.ressourcesdiffusablesapi.config.beans.GARProperties;
Expand All @@ -40,7 +40,7 @@ public class AppProperties {

private CorsProperties cors = new CorsProperties();
private GARProperties gar = new GARProperties();
private SoffitProperties soffit = new SoffitProperties();
// private SoffitProperties soffit = new SoffitProperties();
private NoGARProperties noGar = new NoGARProperties();
private CacheProperties cache = new CacheProperties();

Expand All @@ -55,7 +55,7 @@ public String toString() {
cors + ",\n" +
gar + ",\n" +
noGar + ",\n" +
soffit + ",\n" +
// soffit + ",\n" +
cache + ",\n" +
"\n}";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,56 +14,56 @@
*/
package fr.recia.ressourcesdiffusablesapi.config;

import fr.recia.notifications.soffit_java_client.SoffitJwtAuthenticationFilter;
import fr.recia.notifications.soffit_java_client.SoffitJwtValidator;
import fr.recia.ressourcesdiffusablesapi.config.beans.SoffitProperties;
import lombok.extern.slf4j.Slf4j;
import org.apereo.portal.soffit.security.SoffitApiAuthenticationManager;
import org.apereo.portal.soffit.security.SoffitApiPreAuthenticatedProcessingFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.http.HttpMethod;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import org.springframework.security.web.util.matcher.NegatedRequestMatcher;
import org.springframework.security.web.util.matcher.RequestMatcher;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;


@Slf4j
@Configuration
@Profile("!test")
@EnableWebSecurity
public class SecurityConfiguration {

private final AppProperties appProperties;

public SecurityConfiguration(AppProperties appProperties) {
private final SoffitProperties jwtProperties;

public SecurityConfiguration(AppProperties appProperties, SoffitProperties jwtProperties) {
this.appProperties = appProperties;
this.jwtProperties = jwtProperties;
}

@Bean
public WebSecurityCustomizer webSecurityCustomizer() {
final RequestMatcher pathMatcher = new AntPathRequestMatcher("/api/**");
final RequestMatcher inverseMatcher = new NegatedRequestMatcher(pathMatcher);

return web -> web.ignoring().requestMatchers(inverseMatcher);
@Bean
SoffitJwtValidator soffitJwtValidator() {
return new SoffitJwtValidator(jwtProperties.getJwtSignatureKey());
}

@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
final AbstractPreAuthenticatedProcessingFilter filter = new SoffitApiPreAuthenticatedProcessingFilter(
appProperties.getSoffit().getJwtSignatureKey()
);

filter.setAuthenticationManager(authenticationManager());
SoffitJwtAuthenticationFilter soffitJwtAuthenticationFilter(SoffitJwtValidator validator) {
return new SoffitJwtAuthenticationFilter(validator);
}

http.addFilter(filter);
@Bean
SecurityFilterChain securityFilterChain(HttpSecurity http, SoffitJwtAuthenticationFilter filter) {
http.authorizeHttpRequests(authz -> authz
.antMatchers("/health-check").permitAll()
.antMatchers(HttpMethod.GET, "/api/**").authenticated()
.requestMatchers("/health-check").permitAll()
.requestMatchers(HttpMethod.GET, "/api/**").authenticated()
.anyRequest().denyAll()
);
http.sessionManagement().sessionFixation().newSession();
http.addFilterBefore(filter, UsernamePasswordAuthenticationFilter.class);

return http.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* limitations under the License.
*/

import com.fasterxml.jackson.databind.util.ISO8601Utils;
import fr.recia.ressourcesdiffusablesapi.utils.Utils;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,25 @@
package fr.recia.ressourcesdiffusablesapi.config.beans;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;

import jakarta.annotation.PostConstruct;

@Data
@Slf4j
@ConfigurationProperties(prefix = "app.soffit", ignoreUnknownFields = true)
public class SoffitProperties {

private String jwtSignatureKey;


@PostConstruct
void init(){
log.info(this.toString());
System.out.println(this.toString());
}

@Override
public String toString() {
return "\"SoffitProperties\": {" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@
*/
package fr.recia.ressourcesdiffusablesapi.service.parser.impl;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.cfg.ConstructorDetector;
import com.fasterxml.jackson.databind.json.JsonMapper;

import fr.recia.ressourcesdiffusablesapi.model.RessourceDiffusable;
import fr.recia.ressourcesdiffusablesapi.service.parser.IRessourceDiffusableParserService;
import lombok.extern.slf4j.Slf4j;
import tools.jackson.databind.JsonNode;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.cfg.ConstructorDetector;
import tools.jackson.databind.json.JsonMapper;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
Expand All @@ -39,7 +38,6 @@ public List<RessourceDiffusable> parseRawJsonStringIntoRessourceDiffusableList(S
ObjectMapper mapper = JsonMapper.builder()
.constructorDetector(ConstructorDetector.EXPLICIT_ONLY)
.build();
mapper.configure(DeserializationFeature.FAIL_ON_MISSING_CREATOR_PROPERTIES, false);
JsonNode rootNode = mapper.readTree(rawJsonString);

JsonNode inside = rootNode.get(0);
Expand Down
Loading
Loading