@pixelairport If you know that there’s only going to be one other micro service accessing this service then yeah, you could create some middleware that only accepts requests from a specific IP address:
class CheckRequestIsComingFromUpstreamService
{
public function handle(Request $request, Closure $next)
{
if ($request->ip() === 'XXX.XXX.XXX.XXX') {
return $next($request);
}
abort(403);
}
}
That will reject requests coming from any other IP address. So if someone did get your access tokens, they wouldn’t be able to authenticate and invoke your service from any other machine.
The downside is, this means the upstream service has to have a static IP address, and if the IP address does change, then you need to change either your codebase or a configuration value somewhere.
