Spring Boot 2.0 disable default security

后端 未结 11 2627
闹比i
闹比i 2020-12-02 11:28

I want to use Spring Security for JWT authentication. But it comes with default authentication. I am trying to disable it, but the old approach of doing this - disabling it

11条回答
  •  忘掉有多难
    2020-12-02 11:51

    According to the new updates in Spring 2.0, if Spring Security is on the classpath, Spring Boot will add @EnableWebSecurity.So adding entries to the application.properties ain't gonna work (i.e it is no longer customizable that way). For more information visit the official website Security changes in Spring Boot 2.0

    Albeit not sure about your requirement exactly, I could think of one workaround like the following:-

    @Configuration
    @EnableWebSecurity
    public class SecurityConfiguration  extends WebSecurityConfigurerAdapter{
        @Override
        protected void configure(HttpSecurity http) throws Exception{
            http.authorizeRequests().antMatchers("/").permitAll();
        }
    }
    

    Hope this helps.

提交回复
热议问题