Skip to content

Commit

Permalink
Migration to spring boot 3 (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
olevitt authored Oct 16, 2023
1 parent 5d14bd8 commit 881b6d3
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import fr.insee.onyxia.api.configuration.CatalogWrapper;
import jakarta.annotation.PostConstruct;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import fr.insee.onyxia.model.region.Region;
import fr.insee.onyxia.model.service.Service;
import jakarta.annotation.PostConstruct;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.insee.onyxia.api.configuration.proxy;

import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import fr.insee.onyxia.model.OnyxiaUser;
import fr.insee.onyxia.model.project.Project;
import fr.insee.onyxia.model.region.Region;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.MethodParameter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import fr.insee.onyxia.api.configuration.properties.RegionsConfiguration;
import fr.insee.onyxia.model.region.Region;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.MethodParameter;
import org.springframework.stereotype.Service;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
package fr.insee.onyxia.api.security;

import fr.insee.onyxia.api.services.utils.HttpRequestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.SecurityFilterChain;

@Configuration
@EnableWebSecurity
@ConditionalOnExpression("'${authentication.mode}' == 'none' or '${authentication.mode}' == ''")
public class NoSecurityConfiguration extends WebSecurityConfigurerAdapter {
public class NoSecurityConfiguration {

@Autowired private HttpRequestUtils httpRequestUtils;

@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/**").permitAll();
@Bean
protected SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.authorizeHttpRequests(auth -> auth.anyRequest().permitAll());
http.headers().frameOptions().disable();
http.csrf().disable();
}

@Override
public void configure(WebSecurity web) {
web.ignoring().antMatchers("/**");
return http.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.and()
// manage routes securisation here
.authorizeRequests()
.antMatchers(HttpMethod.OPTIONS)
.requestMatchers(HttpMethod.OPTIONS)
.permitAll()
// configuration pour Swagger
.antMatchers(
.requestMatchers(
"/",
"/swagger-ui**",
"/swagger-ui/**",
Expand All @@ -83,7 +83,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
"/actuator/**",
"/actuator")
.permitAll()
.antMatchers(
.requestMatchers(
"/api",
"/api/swagger-ui**",
"/api/swagger-ui/**",
Expand All @@ -97,9 +97,9 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
"/api/actuator")
.permitAll()
// configuration pour public
.antMatchers("/public/**")
.requestMatchers("/public/**")
.permitAll()
.antMatchers("/api/public/**")
.requestMatchers("/api/public/**")
.permitAll()
.anyRequest()
.authenticated()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.insee.onyxia.api.services.utils;

import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Service;

@Service
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package fr.insee.onyxia.api.configuration;

import fr.insee.onyxia.api.security.NoSecurityConfiguration;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension;

@ExtendWith(SpringExtension.class)
@AutoConfigureRestDocs(outputDir = "target/snippets")
@TestPropertySource("classpath:application-test.properties")
@Import(NoSecurityConfiguration.class)
public abstract class BaseTest {}
6 changes: 0 additions & 6 deletions onyxia-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@
<artifactId>jackson-databind</artifactId>
</dependency>

<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.16</version>
<version>3.1.4</version>
</parent>
<modules>
<module>onyxia-model</module>
Expand Down

0 comments on commit 881b6d3

Please sign in to comment.