Spring Netflix Zuul:验证并路由相同的请求

时间:2015-12-24 08:12:02

标签: spring-security spring-cloud spring-session netflix-zuul

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

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

  • 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上的question做出回应。

0 个答案:

没有答案