Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do communications between internal services need authorization like oauth if the outside world can't access the apis directly?

This is just a general question about microservice architecture. Why do 2 or more internal services still need token auth like oauth2 to communicate with each other if the outside world doesn't have access to them? Couldn't their apis just filter internal IP addresses instead? What are the risks with that approach?

like image 793
u84six Avatar asked Dec 14 '22 08:12

u84six


1 Answers

Why do 2 or more internal services still need token auth like oauth2 to communicate with each other if the outside world doesn't have access to them?

You don't need OAuth2 or token authentication, but you should use it. It depends on how much you trust your traffic. Now in the "cloud age" it is common to not own your own datacenters, so there is another part that own your server and network hardware. That part may do a misconfiguration, e.g. traffic from another customer is routed to your server. Or maybe you setup your own infrastructure and do a misconfiguration so that traffic from your test environment is unintendently routed to your production service. There is new practices to handle this new landscape and it is described in Google BeyondCorp and Zero Trust Networks.

Essentially, you should not trust the network traffic. Use authentication (e.g. OAuth2, OpenID Connect, JWT) on all requests, and encrypt all traffic with TLS or mTLS.

Couldn't their apis just filter internal IP addresses instead? What are the risks with that approach?

See above, maybe you should not trust the internal traffic either.

In addition, it is now common that your end-users is authenticated using OpenID Connect (OAuth2 based authentication) - JWT-tokens sent in the Authorization: Bearer header. Most of your system will operate in a user context when handling the request, that is located within the JWT-token, and it is easy to pass that token in requests to all services that are involved in the operation requested by the user.

like image 76
Jonas Avatar answered Jan 04 '23 01:01

Jonas