0

我有一堆服务位于 Zuul 边缘服务器后面。Zuul Edge Server 也执行身份验证。会话使用 Spring Session 与所有服务共享。我希望能够在同一流程中对请求进行身份验证并将请求路由到服务。我查看了Dave Syer 的教程,其中网关服务器可以验证和路由请求。

在该项目上,以下命令有效:

  • curl -u admin:admin http://localhost:8080/user
  • curl -c cookie.txt -u admin:admin http://localhost:8080/user && curl -b cookie.txt http://localhost:8080/admin/user

我希望这也能正常工作,但事实并非如此:

  • curl -u admin:admin http://localhost:8080/admin/user

我期待网关服务器进行身份验证,创建一个 redis 会话,将请求路由到管理服务,该服务将从 redis 会话中选择身份验证。请求被路由到管理服务,但它也尝试基本身份验证并失败。

这是我在管理服务的日志中看到的:

o.s.s.w.a.www.BasicAuthenticationFilter  : Basic Authentication Authorization header found for user 'admin'
o.s.s.authentication.ProviderManager     : Authentication attempt using org.springframework.security.authentication.dao.DaoAuthenticationProvider
o.s.s.a.dao.DaoAuthenticationProvider    : User 'admin' not found
o.s.s.w.a.www.BasicAuthenticationFilter  : Authentication request for failed: org.springframework.security.authentication.BadCredentialsException: Bad credentials

我收到 HTTP 401 Unauthorized 响应。

我还尝试在管理服务中禁用 HTTP 基本身份验证,但随后我收到 HTTP 403 Forbidden 响应。

有没有办法做到这一点?

更新

我认为这是行不通的,因为 Spring Session 的实现方式是保存会话。我正在等待对我在 github 上的问题的答复。

4

0 回答 0