JAVA-14677 Update spring-boot-keycloak module under spring-boot-modules to remove usage of deprecated WebSecurityConfigurerAdapter (#12842)

This commit is contained in:
anuragkumawat 2022-10-10 23:24:23 +05:30 committed by GitHub
parent f4d7618759
commit 02f8f60d53
1 changed files with 13 additions and 13 deletions

View File

@ -4,14 +4,14 @@ 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.core.session.SessionRegistryImpl; import org.springframework.security.core.session.SessionRegistryImpl;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.session.RegisterSessionAuthenticationStrategy; import org.springframework.security.web.authentication.session.RegisterSessionAuthenticationStrategy;
import org.springframework.security.web.authentication.session.SessionAuthenticationStrategy; import org.springframework.security.web.authentication.session.SessionAuthenticationStrategy;
@Configuration @Configuration
@EnableWebSecurity @EnableWebSecurity
class SecurityConfig extends WebSecurityConfigurerAdapter { class SecurityConfig {
private final KeycloakLogoutHandler keycloakLogoutHandler; private final KeycloakLogoutHandler keycloakLogoutHandler;
@ -24,8 +24,8 @@ class SecurityConfig extends WebSecurityConfigurerAdapter {
return new RegisterSessionAuthenticationStrategy(new SessionRegistryImpl()); return new RegisterSessionAuthenticationStrategy(new SessionRegistryImpl());
} }
@Override @Bean
protected void configure(HttpSecurity http) throws Exception { public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.authorizeRequests() http.authorizeRequests()
.antMatchers("/customers*", "/users*") .antMatchers("/customers*", "/users*")
.hasRole("USER") .hasRole("USER")
@ -36,6 +36,6 @@ class SecurityConfig extends WebSecurityConfigurerAdapter {
.logout() .logout()
.addLogoutHandler(keycloakLogoutHandler) .addLogoutHandler(keycloakLogoutHandler)
.logoutSuccessUrl("/"); .logoutSuccessUrl("/");
return http.build();
} }
} }