更新到 Spring Boot 1.5.8 和 Finchley/Edgware Spring Cloud 后假装异常 403

Feign Exception 403 after updating to Spring Boot 1.5.8 and Finchley/Edgware Spring Cloud

我对微服务比较陌生,我一直在尝试使用这个 proof-of-concept application,它使用 Spring BootSpring Cloud

问题是,虽然应用程序在 Spring Boot 1.3.5Spring Cloud Brixton.RELEASE 上运行良好,但在升级其中任何一个时它会中断。

注册新账号时出现错误,报错如下:

status 403 reading AuthServiceClient#createUser(User); content:↵{"timestamp":1510753211255,"status":403,"error":"Forbidden","message":"Access Denied","path":"/uaa/users"}

和堆栈跟踪:

2017-11-15 15:40:11.284 ERROR 9072 --- [nio-6000-exec-1] o.a.c.c.C.[.[.[.[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [/accounts] threw exception [Request processing failed; nested exception is feign.FeignException: status 403 reading AuthServiceClient#createUser(User); content: {"timestamp":1510753211255,"status":403,"error":"Forbidden","message":"Access Denied","path":"/uaa/users"}] with root cause

因为这似乎是一个 Feign 错误,而且 AuthServiceClient.java 似乎是罪魁祸首,所以我将其包含在此处:

@FeignClient(name = "auth-service")
public interface AuthServiceClient {

@RequestMapping(method = RequestMethod.POST, value = "/uaa/users", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
void createUser(User user);

}

由于代码没有任何更改,我不明白可能是什么原因以及如何解决此错误。

显然是有这种魔法 属性 让它再次起作用:

security.oauth2.resource.filter-order: 3 

auth-service.properties

在这里进一步阅读: