更新到Spring Boot 1.5.8和Finchley / Edgware Spring Cloud之后的Feign Exception 403

时间:2017-11-16 17:17:07

标签: java spring oauth-2.0 microservices netflix-feign

我对微服务比较陌生,我一直在尝试使用这个使用Spring Boot和Spring Cloud的概念验证应用程序: https://github.com/sqshq/PiggyMetrics

问题在于,虽然应用程序在Spring Boot 1.3.5和Spring 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

由于这似乎是一个假设错误,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);

}

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

1 个答案:

答案 0 :(得分:2)

显然有一个神奇的属性使它再次起作用:

security.oauth2.resource.filter-order: 3

auth-service.properties

中的

进一步阅读: SpringBoot 1.5.x + Security + OAuth2