【问题标题】:Why am I getting 403 forbidden when I try to validate JWT from Zuul Proxy?当我尝试从 Zuul 代理验证 JWT 时,为什么会出现 403 被禁止?
【发布时间】:2021-01-05 05:57:08
【问题描述】:

我已经在 Eureka 上注册了 authentication-service 并使用 Zuul 代理进行了身份验证。这是 Zuul 服务的 application.properties 文件:

server.port=8090
zuul.routes.authentication-service.url=http://localhost:8095
ribbon.eureka.enabled=false
zuul.sensitive-headers=Set-Cookie,Authorization

http://localhost:8095/login 映射用于身份验证,http://localhost:8095/validate 用于验证令牌。由于 zuul 代理,我可以从 http://localhost:8090/authentication-service/ 访问这些资源。 /login 映射工作正常,但是当我尝试 http://localhost:8090/authentication-service/validate 并在“授权”中传递令牌时,我得到“拒绝访问”。这就是我在 Postman 中所拥有的:

{
    "timestamp": "2020-09-18T09:30:35.543+00:00",
    "status": 403,
    "error": "Forbidden",
    "message": "Access Denied",
    "path": "/validate"
}

但是当我通过相同的令牌 http://localhost:8095/validate 时,我得到了想要的结果。

我在这里缺少什么?从 Zuul 传递令牌是否有问题?我该如何解决这个问题?

【问题讨论】:

    标签: java jwt netflix-zuul


    【解决方案1】:

    您必须在 sensitive-headers 配置中删除 Authorization

    Zuul 自动删除敏感标头中指定的标头。 因此,您的令牌将从您的请求中删除。

    【讨论】:

      猜你喜欢
      • 2015-09-18
      • 2019-02-26
      • 2013-01-03
      • 2019-07-07
      • 1970-01-01
      • 2014-08-31
      • 2014-10-16
      • 1970-01-01
      • 2020-02-17
      相关资源
      最近更新 更多