Spring Boot 2.0 disable default security

后端 未结 11 2606
闹比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:57

    According to the reference documentation, the Security configuration for allowing all requests with WebFlux should look like this:

    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.security.config.web.server.ServerHttpSecurity;
    import org.springframework.security.web.server.SecurityWebFilterChain;
    
    @Configuration
    public class SecurityConfig {
    
        @Bean
        public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
            http.authorizeExchange().anyExchange().permitAll();
            return http.build();
        }
    }
    

提交回复
热议问题