JAVA-27656 | spring-boot-modules fix

This commit is contained in:
gaepi 2023-11-27 11:31:41 +01:00
parent 8548b42b84
commit 2e6b17b853
2 changed files with 15 additions and 12 deletions

View File

@ -1,9 +1,10 @@
package com.baeldung.caffeine; package com.baeldung.caffeine;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity; 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.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.web.SecurityFilterChain;
/** /**
* Because the POM imports Spring Security, we need a simple security * Because the POM imports Spring Security, we need a simple security
@ -11,14 +12,14 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
*/ */
@Configuration @Configuration
@EnableWebSecurity @EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter { public class SecurityConfiguration {
@Override @Bean
protected void configure(HttpSecurity http) throws Exception { public SecurityFilterChain securityFilter(HttpSecurity http) throws Exception {
http.csrf().disable(); http.csrf().disable();
http.authorizeRequests() return http.authorizeRequests()
.antMatchers("/**") .antMatchers("/**")
.permitAll(); .permitAll().and().build();
} }
} }

View File

@ -1,14 +1,16 @@
package com.baeldung.spring.boot.management.logging; package com.baeldung.spring.boot.management.logging;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.web.SecurityFilterChain;
@Configuration @Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter { public class SecurityConfig {
@Override @Bean
protected void configure(HttpSecurity http) throws Exception { public SecurityFilterChain securityFilter(HttpSecurity http) throws Exception {
http.csrf() return http.csrf()
.ignoringAntMatchers("/actuator/**"); .ignoringAntMatchers("/actuator/**").and()
.build();
} }
} }