Increase in Eureka
Projects previously authorized services and resources are two separate services, such check_token address resources in the service of the write address are dead:
Here we add the eureka, so that you can directly use the service name. Build eureka services are not discussed, in the service plus eureka only need to change two places, it is to add and modify the configuration dependent:
Increase the allocation is as follows:
Then you can put the resources in the service of fixed ip service name was changed to:
Relay token increase
After obtaining a token from the authorization service, direct access to a resource service is no problem, but if the resource service calls went to other resources services, the question arises, is the token can not be automatically passed down. To achieve the token relay we need to write an interceptor, the token header into the request.
First increase feign components in the service:
Increase in notes @EnableFeignClients:
Note that the above dependence and notes the caller and callee will also increase. Then write an interface to the called party:
Use feign call the caller:
Then write a test interface in the caller:
Now apply directly for a token, and then access the caller test interface, the following 401 error:
The following increase in the caller an interceptor, a token increase in the header:
test
Directly apply the following token, access to the caller's test interface, you can see the results of token relay:
Code Address: https: //gitee.com/blueses/spring-boot-security 30 31 32 33
This article from the blog article multiple platforms OpenWrite release!