I have a backend API that is hosted in Azure app service. I want to use Azure API management as the front end to this backend API and have successfully configured this in Azure. I have configured API management to use OAuth when accessing this backend API which works when clients access the API through the Azure API management endpoints, but how do I prevent people from accessing the backend API endpoints directly so that only calls from the API management endpoints are allowed?
Asked
Active
Viewed 3,606 times
2 Answers
4
There are a few options of various levels of security:
- Shared secret - set a certain header with a certain value in APIM and check that value at your backend.
- Managed identity - you can enable managed identity in APIM service and send its token to your backend where you'll be able to validate it.
- IP filter - check for APIM IP as a source at backend.
- Client certificate auth - upload a client cert auth to APIM and attach it to every request to backend. Check for that cert at backend.
- VNET - put APIM and your backend into same VNET and block access from outside to backend.

Vitaliy Kurokhtin
- 7,205
- 1
- 19
- 18
-
I wonder how come two solid options are not included here: 1- Pass the Barear token to the backend API and have the backend validate it. 2- Add OAuth to the backend and make API management pass through. – Allan Xu Nov 13 '18 at 16:58
-
1As I understand @Geekn already made it so that APIM sends bearer token with every request. The question is about making it impossible to call backend API directly at all, and not just without a token. – Vitaliy Kurokhtin Nov 13 '18 at 22:44
-
Yeah, the thing is that APIM adds gateway restrictions, rate limits, caching, etc.. – Juan Carrey Nov 11 '21 at 09:17
1
I've personally used IP restrictions to great success. APIM is given a static IP, so you can setup an IP restriction in the "root API" that allows only the APIM calls. This results in a 403 if you call the root API directly.
If you don't want a 403 coming from the root API, you can use policies to change that, or you can setup authentication at the APIM level and you'll get a 401 before even hitting that 403.

ZE7EN
- 83
- 6