Introducing agnostic discussion.
Suppose the following diagram. 
- Black lines indicate which services are protected by the auth server.
- The green lines show the interaction between the services (customers and order services must go through a data service that will access the database. StandAlone does not like other services).
- Red line shows a specific request stream
- The data service is not displayed directly from the outside and can only be accessed by other services that are allowed to do so.
I make the assumption that the client received the access token when the user authenticated on the auth server. Which stream was selected (implicit, authorization code, password) does not matter. I would like to start the discussion from the moment when the client has already received the access token.
From this moment it becomes clear to me what happens when a client needs access to a single resource server.
- Make a request to the resource server and transfer the purchased token
- The resource server checks the token (irrelevant)
- If appropriate, submit a request.
So, in this diagram, if the client was to access the "StandAlone Service" (which does not talk to any other resource server), the flow is clear to me.
I am having problems when the client follows the red line in the diagram. Therefore, I need to access a service (resource server), which, in order to respond, must access another service (also a resource server). How is the flow going in this case?
Scenario 1.
- The Orders service is installed on both the resource server and the client.
- The client makes a request using the access token, but the Orders service will receive another token with its client credentials in order to talk to the Data Service.
The problem here, as I see it, is that I'm losing user rights. I made a request to the "data service" with the permissions "Order the service", and not with user rights.
Scenario 2.
- The Orders service is configured only as a resource server.
- The client makes a request with a user token, and the Orders service sends the same token to the Data Service
Here I execute with user permissions, but now I see that my "Data Service" is open and open to any other service. (Actually, I donāt know if oauth2 provides such a restriction. Client restriction only on certain resource servers)
Scenario 3.
Here I see a combination of the above scenarios in which the Order Service will provide both tokens to the data service. The userās access token, so that the request is executed with the correct permissions and the clientās access token is āService Orderā, so that I know that the service is allowed to talk to the āData Serviceā.
Implementation
I use spring to boot and spring to configure my oauth2 components discussed above. I already have an auth server, resource server and client. The client is currently talking to the resource server without transferring the request to another resource server.
Depending on the best approach, how should I go on the implementation side? What changes do I need to make to my resource servers so that they can talk to each other safely?
thank you for your time