Implementation agnostic discussion.
- Black lines show which services are protected by the auth server.
- Green lines show interaction between services(Customer, and Orders services need to go through the Data service which will access the database. StandAlone service doesn't like other services)
- Red line show a specific request flow
- Data service is not exposed directly to the outside and can be accessed only by other services that are allowed to do so.
I make the assumption that the client has obtained an access token when the user authenticated with the auth server. Which flow was picked(implicit, authorization code, password) is irrelevant. I would like to start the discussion from the point where the client has already obtained the access token.
From that point on, it is clear to me what happens when the client needs to access a single resource server.
- Make request to resource server and pass acquired token
- Resource server validates the token (irrelevant how)
- If valid, serve request.
So in that 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 trouble when the client follows the red line in the diagram. So i need to access a service(resource server) which in order to reply needs to access another service(also resource server). How does the flow go in that case?
Scenario 1.
- The "Orders service" is setup both as a resource server and as a client.
- Client makes request with the access token but the "Orders service" will acquire another token with its own client credentials in order to talk to the "Data service".
The problem here as i see it is that i loose the user permissions. I will execute the request to the "Data service" with the "Order's service" permissions and not the user's permissions.
Scenario 2.
- The "Orders service" is setup only as a resource server.
- Client makes request with the user token and the "Orders service" will forward the same token down to the "Data service"
Here i execute with the user's permissions but now i see that my "Data service" is exposed and open to any other service. (Actually i don't know if oauth2 provides such limitation. Restrict a client only to specific resource servers)
Scenario 3.
Here i see a combination of the above scenarios where the "Orders service" will provide both tokens to the data service. The user access token so that request is executed with the right permissions and the "Order's service" client access token so that i know that the service is allowed to talk to the "Data service".
Implementation
I am using spring boot and spring security in order to setup my oauth2 components seen above. I already have an auth server, a resource server and a client. The client at the moment talks to a resource server without the request being delegated to another resource server.
Depending on the best approach how would i go on the implementation side? What changes do i need to make to my resource servers so that they can talk securely to each other?
Thank you for your time