2 个微服务和其中一个微服务之间与 openFeign 的 Forbbiden 通信使用 jwt 令牌是安全的

时间:2021-05-25 18:05:48

标签: spring-boot spring-security microservices openfeign

我设法为微服务用户添加了安全性。但我现在面临的问题是,我无法使用 open feign 使微服务(用户微服务和票证微服务)相互通信,因为其中之一现在由 Spring Security 和 JWT 保护。请问我该如何解决这个问题?

这是我的控制器的一部分

    @GetMapping("/find-ticket/{id}")
    public ResponseEntity<Ticket> findTicketById(@PathVariable("id") UUID ticketId)
    {
        Ticket ticket= ticketService.findTicketById(ticketId);
        ticket.setUser(userService.findUserById(ticket.getUserId()));
        ResponseEntity<Ticket> responseEntity = new ResponseEntity<>(ticket, HttpStatus.OK);
        return responseEntity;

    }

这是工单微服务的UserService接口

@FeignClient(name = "USER-SERVICE")
public interface UserService {
    @GetMapping("/find-user/{id}")
    public User findUserById(@PathVariable(name = "id") UUID USER_ID);
}

and this is the image of the error i got

0 个答案:

没有答案