【问题标题】:Spring boot, zuul, oauth2 authentication problemspring boot、zuul、oauth2认证问题
【发布时间】:2021-06-22 05:04:43
【问题描述】:

我一直在尝试使用 Zuul、Eureka 和 Spring boot 构建应用程序,最近我决定尝试登录。提醒一下,我已经配置了身份验证服务(使用 OAuth 2.0),并且可以使用 CURL 成功进行身份验证。我还可以向其他具有受保护资源的微服务发出请求(同样只能使用 CURL,因为我可以在身份验证标头中注入令牌)。我担心的是我想用 Zuul 作为网关来做这件事。 [![在此处输入图片描述][1]][1]

Zuul 运行在端口 8080 和 身份验证服务在端口 1992 上运行 当我直接在 http://localhost:19992/oauth/token 端点上调用身份验证服务时,它会生成如下令牌。 [![在此处输入图像描述][2]][2] 但是,当我尝试通过 zuul 服务器访问身份验证服务时,它显示未授权 http://localhost:8080/auth-service/oauth/token [![在此处输入图片描述][3]][3]

我的 Zuul Server application.yml 配置

eureka:
  client:
    register-with-eureka: true
    fetch-registry: true
  instance:
    hostname: zuul-service
    instance-id: ${eureka.instance.hostname}:${random.int}
    prefer-ip-address: true
zuul:
  sensitive-headers: Cookie,Set-Cookie,Authorization```

My Question is
1. why token is not generated through zuul server?
2. How token propagate through multiple microservices?

Any help is much appreciated. 
Thanks in advance. 
  [1]: https://i.stack.imgur.com/bQUvE.png
  [2]: https://i.stack.imgur.com/Spsqf.png
  [3]: https://i.stack.imgur.com/yp84x.png

【问题讨论】:

    标签: java spring spring-boot microservices netflix-zuul


    【解决方案1】:

    我一直在 sensativeHeaders 中添加授权。 这将不允许 Authorization 标头传播下游服务。我从敏感标题中删除了授权,然后它就像魅力一样工作。

    【讨论】:

      猜你喜欢
      • 2016-06-29
      • 1970-01-01
      • 2016-10-06
      • 2020-09-08
      • 2022-08-24
      • 2016-10-28
      • 2018-12-01
      • 2018-01-12
      • 2017-04-11
      相关资源
      最近更新 更多