JAVA-14682 Update spring-boot-keycloak-2 module under spring-boot-modules to remove usage of deprecated WebSecurityConfigurerAdapter (#12927)

This commit is contained in:
anuragkumawat 2022-10-29 02:21:56 +05:30 committed by GitHub
parent 38fba9ca9b
commit e506e68202

View File

@ -1,20 +1,23 @@
package com.baeldung.disablingkeycloak; package com.baeldung.disablingkeycloak;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
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
@ConditionalOnProperty(name = "keycloak.enabled", havingValue = "false") @ConditionalOnProperty(name = "keycloak.enabled", havingValue = "false")
public class DisableSecurityConfiguration extends WebSecurityConfigurerAdapter { public class DisableSecurityConfiguration {
@Override @Bean
protected void configure(final HttpSecurity http) throws Exception { public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.csrf() http.csrf()
.disable() .disable()
.authorizeRequests() .authorizeRequests()
.anyRequest() .anyRequest()
.permitAll(); .permitAll();
return http.build();
} }
} }