Thank you for your time. To make it simple, I created an example service, as shown below:
@RestController @RequestMapping("/") public class ComputeController { @GetMapping("/add") public int add(@RequestParam("left") int left, @RequestParam("right") int right) { return left + right; } }
To protect this url, I config spring-security like this:
management.security.enabled=true security.user.name=admin security.user.password=admin
When I start this service and access it like this:
GET /add?left=100&right=11 HTTP/1.1 Authorization: ***** Hidden credentials ***** Host: localhost:7777 Connection: close
Everything goes well.
In another node, I created a “service compiler” using netflix feign. This is the Java interface.
@FeignClient(name = "API-GATEWAY", path = "/compute-service", fallback = ComputeServiceCircuitBreaker.class) public interface ComputeServiceClient { @RequestMapping(path = "/add", method = RequestMethod.GET) public Integer add(@RequestParam("left") Integer left, @RequestParam("right") Integer right); }
But I do NOT know how to configure the header of the "Authorization" request.
Any idea? Thanks again.
source share