spring启动,zuul,oauth2身份验证问题

rur96b6h  于 2021-07-15  发布在  Java
关注(0)|答案(1)|浏览(282)

我一直在尝试用zuul、eureka和spring boot构建一个应用程序,最近我决定尝试登录。作为提醒,我已经配置了身份验证服务(使用OAuth2.0),并且可以使用curl成功地进行身份验证。我还可以向其他具有受保护资源的微服务发出get请求(同样只使用curl,因为我可以在身份验证头中注入令牌)。我担心的是,我想用zuul做为一个门户[在此处输入图像描述][1]][1]
当我直接调用上的身份验证服务时,zuul在端口8080上运行,auth服务在端口1992上运行http://localhost:19992/oauth/token endpoint,它正在生成令牌,如下所示。[[在此处输入图像描述][2]][2]但是,当我尝试通过zuul服务器访问身份验证服务时,它显示未授权rizedhttp://localhost:8080/auth-service/oauth/token[[在此处输入图像描述][3]][3]
myzuul 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
vddsk6oq

vddsk6oq1#

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

相关问题