【问题标题】:Disable webflux security禁用 webflux 安全性
【发布时间】:2019-03-30 20:53:18
【问题描述】:

有没有办法通过一些配置或通过 pom 修改来禁用 web-flux 安全的安全性。现在我已经使用

禁用它
  @Bean  public SecurityWebFilterChain securityWebFilterChain(final ServerHttpSecurity httpSecurity) {
return httpSecurity
        .authorizeExchange().anyExchange().permitAll().and()
        .build();  }

这是在生产环境中执行此操作的最佳方式吗? 每当我添加依赖项以从配置服务器读取值时,spring security 都会进入类路径并出现弹出窗口。我不想要安全,因为我们有自己的安全。

【问题讨论】:

    标签: spring-boot spring-security spring-webflux


    【解决方案1】:

    您可以使用仅在特定上下文中运行的配置/配置文件类,例如:

    @Configuration
    @Profile("dev")
    public class SecurityConfig {
        @Bean
        public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
            return http.authorizeExchange().anyExchange().permitAll().and().build();  
        }
    
    }
    

    然后,如果您希望它作为应用程序的一部分运行,您可以运行:

    mvn spring-boot:run -Dspring-boot.run.profiles=dev
    

    或者您可以将其包含在 properties/yaml 文件中。希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 2020-11-18
      • 2019-12-28
      • 2021-06-23
      • 2019-02-05
      • 2017-12-20
      • 1970-01-01
      • 2020-07-18
      • 2023-03-03
      • 2021-05-11
      相关资源
      最近更新 更多