Securing endpoints to specific IP addresses to prevent unauthorized access is a common practice in Backend engineering particularly for sensitive endpoints.
An Example is Securing Webhook endpoints E.g. Paystack
The files Attached
- main.go :: Houses the server
- middleware.go :: Houses the IP whitelisting function
The approach is to have selected endpoints available to only selected IP addresses by taking advantage of Gin's middleware Approach
- This example can't be tested out locally
- Supply real IP addresses to the IpWhitelist map