JAVA-14680 Update spring-boot-admin module under spring-boot-modules to remove usage of deprecated WebSecurityConfigurerAdapter (#12732)
This commit is contained in:
parent
fe187e8f98
commit
919da4dfe6
|
@ -2,11 +2,12 @@ package com.baeldung.springbootadminserver.configs;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
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;
|
||||||
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
|
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
|
||||||
import org.springframework.security.web.csrf.CookieCsrfTokenRepository;
|
import org.springframework.security.web.csrf.CookieCsrfTokenRepository;
|
||||||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||||
|
@ -15,15 +16,15 @@ import de.codecentric.boot.admin.server.config.AdminServerProperties;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebSecurity
|
@EnableWebSecurity
|
||||||
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
public class WebSecurityConfig {
|
||||||
private final AdminServerProperties adminServer;
|
private final AdminServerProperties adminServer;
|
||||||
|
|
||||||
public WebSecurityConfig(AdminServerProperties adminServer) {
|
public WebSecurityConfig(AdminServerProperties adminServer) {
|
||||||
this.adminServer = adminServer;
|
this.adminServer = adminServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Bean
|
||||||
protected void configure(HttpSecurity http) throws Exception {
|
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||||
SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
|
SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
|
||||||
successHandler.setTargetUrlParameter("redirectTo");
|
successHandler.setTargetUrlParameter("redirectTo");
|
||||||
successHandler.setDefaultTargetUrl(this.adminServer.getContextPath() + "/");
|
successHandler.setDefaultTargetUrl(this.adminServer.getContextPath() + "/");
|
||||||
|
@ -54,5 +55,6 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||||
.key(UUID.randomUUID()
|
.key(UUID.randomUUID()
|
||||||
.toString())
|
.toString())
|
||||||
.tokenValiditySeconds(1209600);
|
.tokenValiditySeconds(1209600);
|
||||||
|
return http.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue