【问题标题】:Is it possible to disable security on spring cloud stream starter apps?是否可以禁用 Spring Cloud Stream Starter 应用程序的安全性?
【发布时间】:2018-07-02 12:07:04
【问题描述】:

我正在玩 Spring Cloud Data Flow。我已经使用相关的documentation 在 Kubernetes 上成功部署了 SCDF。注册1.5.x based starter apps 时,一切都按预期工作,在部署流定义期间不需要进一步配置启动应用程序。

使用2.x based starter apps 时,切换到 Spring Boot 2.0 引入了一些需要适应的变化,例如执行器端点发生了变化。作为参考,以下是我在部署流期间提供的属性:

app.*.management.endpoints.web.exposure.include=health,info,binders
deployer.*.cpu=2
deployer.*.memory=4096
deployer.http.count=2
deployer.*.kubernetes.livenessProbePath=/actuator/health
deployer.*.kubernetes.readinessProbePath=/actuator/info

但是,就绪探测失败,因为healthinfo 端点现在似乎默认受到保护。因此,pod 最终会陷入崩溃循环,因为从 Kubernetes 的角度来看,它们永远不会准备好。

我按照我的流定义所依赖的patching the starter apps 上的指南(例如throughput sink)解决了这种情况,如下所示:

@SpringBootApplication
@Import({org.springframework.cloud.stream.app.throughput.sink.ThroughputSinkConfiguration.class})
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

    @Configuration
    protected static class ThroughputSinkSecurityConfiguration extends WebSecurityConfigurerAdapter {

        @Override
        protected void configure(HttpSecurity http) throws Exception {
            http
                .authorizeRequests()
                .requestMatchers(EndpointRequest.to("health", "info")).permitAll();
        }

    }
}

有没有办法通过标志或属性来指定这种安全配置?默认情况下不应该有这样的WebSecurityConfigurerAdapter 以使healthinfo 端点可供Kubernetes 访问吗?

【问题讨论】:

    标签: java spring-boot kubernetes spring-cloud-stream spring-cloud-dataflow


    【解决方案1】:

    Artem 的回答非常中肯。我还想分享一些其他特定于安全和 OOTB 应用程序的方法。

    1. 在 1.6 SNAPSHOT 中,我们最近通过 spring-cloud/spring-cloud-deployer-kubernetes#236 添加了支持,以插入 basic-auth 领域以与安全执行器端点进行交互。它们适用于 liveness 和 readiness 探针。这是commit/docs 供您参考。

    2. 如果您根本不想要安全性(尽管不推荐),您可以显式禁用安全性配置。

    dataflow:>stream create foo -- 定义“http | 吞吐量”

    dataflow:>stream deploy foo --properties app.*.spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration"

    (即,foo 流定义中的所有应用程序都将以 SecurityAutoConfiguration 开头)

    【讨论】:

    • 感谢萨比。我也是这么看的,是的,Artems 的响应是生产的方式。在这个阶段我需要一种快速禁用安全配置的方法,所以你的回答对我来说最相关。
    【解决方案2】:

    我建议从另一个角度研究这种情况,并提供来自 Kubernetes 的凭据以访问您的安全微服务。

    所有资源都必须受到保护的现状问题。

    您可以生成自己的静态密码并将其存储在application.properties 每次应用重启时不要重新配置Kubernetes:https://docs.spring.io/spring-boot/docs/2.0.3.RELEASE/reference/htmlsingle/#boot-features-security

    【讨论】:

      猜你喜欢
      • 2023-03-03
      • 1970-01-01
      • 1970-01-01
      • 2019-04-27
      • 2011-09-17
      • 1970-01-01
      • 2019-08-03
      • 2019-06-10
      • 2017-03-22
      相关资源
      最近更新 更多