gpt4 book ai didi

java - 是否可以禁用 spring cloud stream starter 应用程序的安全性?

转载 作者:行者123 更新时间:2023-11-29 08:27:43 25 4
gpt4 key购买 nike

我正在玩弄 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 默认情况下让 Kubernetes 可以访问 healthinfo 端点吗?

最佳答案

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

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

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

dataflow:>stream create foo -- definition "http | throughput"

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

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

关于java - 是否可以禁用 spring cloud stream starter 应用程序的安全性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51135871/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com