'How to retrieve Data belongs to a User from a Microservice?

In the past, I had a Spring Boot backend and a frontend. For all requests, I checked the principal in the backends controller, to find out who was requesting the data, creating a response with data that only belonged to that user. That worked fine.

Actually I have a

  • Spring Cloud Gateway
  • Eureka Server
  • UserAuthService
  • ToDoListService

As client I need to login to obtain a JWT, with that JWT I can do requests to my Gateway like

GET localhost:8080/todo-service/my-todos

My Gateway checks the JWT (isValid or not) and pass the request to my ToDoListService.

Pls give me a suggestion to a good practice how to find out in my ToDoListService which user data I need to response.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source