【问题标题】:Have Zuul edge service automatically use microservice's basic auth credentials让 Zuul 边缘服务自动使用微服务的基本身份验证凭据
【发布时间】:2018-01-11 21:16:10
【问题描述】:

我正在尝试构建一个使用zuul通过Eureka调用微服务的边缘服务。微服务需要基本身份验证。以前,功能区会检测凭据并设置身份验证标头。但是现在当我通过 zuul 代理访问端点时,它会提示我使用微服务凭据登录。

有人能告诉我如何配置 zuul 来做 Ribbon 一直在做的事情吗?还是根本不可能?

Spring cloud 版本是 Dalston

spring boot 1.5.6.RELEASE

边缘服务使用 cas 身份验证

zuul 配置

zuul:
    routes:
        my-msv:
            # for now
            sensitiveHeaders:

主类

@SpringBootApplication
@EnableZuulProxy
@RestController
class ZuulDemoApplication {


    @LoadBalanced
    @Bean
    fun restOps(): RestOperations {
        return RestTemplate()
    }

    @GetMapping("/hello")
    fun sayHello() = "hello!"

}

fun main(args: Array<String>) {
    SpringApplication.run(ZuulDemoApplication::class.java, *args)
}

【问题讨论】:

    标签: netflix-zuul spring-cloud-netflix


    【解决方案1】:

    让你的 Zuul 代理成为发现客户端:

    @SpringBootApplication
    @EnableDiscoveryClient // <--- This should do it with defaults
    @EnableZuulProxy
    @RestController
    class ZuulDemoApplication {
    
    
        @LoadBalanced
        @Bean
        fun restOps(): RestOperations {
            return RestTemplate()
        }
    
        @GetMapping("/hello")
        fun sayHello() = "hello!"
    
    }
    
    fun main(args: Array<String>) {
        SpringApplication.run(ZuulDemoApplication::class.java, *args)
    }
    

    【讨论】:

      猜你喜欢
      • 2016-05-31
      • 2019-09-23
      • 1970-01-01
      • 2020-09-25
      • 1970-01-01
      • 2018-07-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多