Search code examples
javaspringoauth-2.0microservicesfeign

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


I'm relatively new to microservices and I've been trying to use this proof-of-concept application that uses Spring Boot and Spring Cloud.

The problem is that, while the app runs fine on Spring Boot 1.3.5 and Spring Cloud Brixton.RELEASE, it breaks when upgrading either one of them.

The error occurs when registering a new account, and it gives the following error:

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

And the stack trace:

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

As this seems to be a Feign error, and AuthServiceClient.java seems to be the culprit, I've included it here:

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

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

}

As there have been no changes to the code whatsoever, I don't understand what the cause could be and what to do to fix this error.


Solution

  • Apparently there was this magic property that made it work again:

    security.oauth2.resource.filter-order: 3 
    

    in auth-service.properties

    Further reading here: SpringBoot 1.5.x + Security + OAuth2