An API Gateway is a mediator between the client and the collection of backend services. It accepts all API calls and routes them to one or more appropriate backend services. It doesn’t stop there; it aggregates appropriate data/ resources and delivers it to the user in a unified manner.
Placed in front of the API/ group of microservices, the API gateway is the single-entry point for all API calls made to and executed by the app. In doing so, it offers an additional layer of security for the app/ microservices.
Having understood what an API gateway is, let us now understand the functions it can perform:
The headless microservice architectures of today are modular and flexible. Unlike traditional, monolithic apps, the applications’ front and back end are decoupled. The front end is a presentation layer, and the back comprises APIs and microservices. This enables developers to create agile, lightweight, and flexible apps that deliver seamless multichannel experiences to users.
But this architecture brings a significant challenge. The microservices and APIs have large numbers of smaller, independent, and single-function components. These are loosely coupled and have separate databases attached to them.
This means that when a user requests, several APIs and microservices need to be called to send appropriate responses. In trying to collect necessary data from multiple APIs and sending a response, there will be multiple round trips between the client and the backend. This leaves the app with higher chances of network latency when an API gateway isn’t deployed.
An API gateway is like a conductor that takes user requests, aggregates all resources, matches user requests to the right backend resources, and returns the requested data. API gateway helps reduce the number of round trips between the client and the app (whether hosted on-premise or in the cloud) in servicing an API request.
The 3 key processes in how API gateway process and service API requests are:
API Gateway standardizes the communication process between apps, services, data, and internal and external users. It acts as a bridge between web protocols that users understand and the internally used complex protocols. It ensures error-free, quick, and seamless servicing of API requests.
For instance, an e-commerce app may deploy an API gateway to combine results for various services, such as offers, discounts, product info, customer reviews, etc., to create frictionless user experiences. The user need not individually ping the app for each piece of information in different APIs or microservices.
Both API gateway and API proxy process API requests and enable easy access to backend services. Like the gateway, the API proxy can communicate between the client and the target API endpoints. It can also control the traffic flow between clients and backend services.
The key point of difference is that API Gateway is more complex and feature-rich, making it suitable for managing APIs in microservices architectures or complex API ecosystems. API Proxy is more straightforward and often used when you need basic routing and forwarding capabilities.
Load balancer reduces the load on the server by smoothing out demand across multiple resources by diverting traffic. The API gateway can also ease load and balance traffic but not as effectively as a load balancer.
API gateway leverages authentication and authorization rules to ensure requests are securely and quickly serviced to authorized users. It can further be equipped with more security controls to ensure greater levels of security. For instance, you can implement WAF with an API gateway to harden your security posture.
But load balancer doesn’t have any hard and fast rules. The decision for traffic diversion is made based on the user’s location and which resources/ servers are free. And they don’t handle security by themselves.
API Gateway operates at the application layer (Layer 7 of the OSI model), whereas Load Balancer typically operates at the transport or network layer (Layer 4 or Layer 3). This means API Gateway has a deeper understanding of the content of API requests and responses.
Service mesh facilitates and controls service-to-service communications over the enterprise network. It is a dedicated infrastructure layer that mostly handles internal communications. What an API gateway does, on the other hand, is to promote the centralization of API communications. It facilitates API-client communications with both internal and external users and devices.
The key responsibility of service mesh is to boost network performance and portability, while that of the API gateway is the management and safety of all APIs. The roles of both tools are complementary. This is why deploying a gateway in front of the service mesh helps ensure much higher security and operational speed.
API Gateway typically operates between external clients and the microservices at the network’s edge, whereas Service Mesh operates within the infrastructure, intercepting and managing traffic between microservices.
Often interchangeably used, API management and gateway are different. An API gateway is but a part of the API management system. Typically, the gateway will intercept incoming API requests and send them to the API management system.
API management is a broader and holistic practice/ system of managing APIs and their resources, data, performance, availability, and security. It includes API key management, policy creation, monitoring API usage, creating developer portals, analytics, etc.
API Gateway primarily focuses on the runtime aspects of managing and controlling API traffic, such as routing, security, and transformation. API Management covers the end-to-end API lifecycle, including design, documentation, deployment, monitoring, and developer engagement.
While API gateway have several benefits, there are also some challenges.
There are several ways in which API gateways boost the API security posture of the organization:
Reduces the Attack Surface: By acting as a barrier and buffer zone, the gateway ensures fewer endpoints are directly exposed to the client. Doing so reduces the attack surface and adds a layer of security.
Authentication and Access Controls: Secure API gateways tuned with authentication and access control policies ensure that only authorized users access data, resources, and APIs after proper user validation.
Input Validation: The gateway rejects the request unless API requests follow the correct format and have all the necessary information. Only validated requests reach the API.
Logging and Monitoring: Gateway tracks, monitors, and controls all incoming API traffic and API responses. So, it offers you critical insights, reports, logs, and centralized visibility into API usage, performance, traffic, and issues. So you can fix security problems right away.
Rate Limiting: When tuned appropriately, a secure API gateway monitors traffic from all sources and rate limits client requests within specific time periods. This protects the API from getting DDoS-ed or crashing.
Here is the complete replay of the webinar “Comprehensive Risk-based API Protection .”
The short clip highlights the critical point – relying only on an API gateway may leave gaps in your API protection strategy.
While the API gateway is integral to an API deployment strategy, it may fail to provide the comprehensive and advanced security features necessary to combat advanced security challenges effectively.
For instance, gateways are ineffective against BOLA (Broken Object Level Authorization) attacks. The API traffic in BOLA may seem normal to the gateway and may process the request. This is because it lacks contextual awareness and behavioural analysis capabilities. As a result, it leaves you exposed to BOLA attacks and business logic attacks.
The other challenge is that the API gateway doesn’t have API discovery and inventorying capabilities. There may be zombie and shadow APIs in your architecture. These APIs could have been deployed by a former employee or a developer unaware of the policies.
In either case, the requests from these APIs don’t get routed through the gateway, so it lacks visibility into all API traffic. And without visibility, you can’t be assured of the security of your APIs.
Your gateway needs to be augmented with API-specific security solutions for effective API protection.
AppTrana offers real-time risk-based protection that adapts to evolving threats and secures APIs. The comprehensive approach includes various crucial steps, including API discovery, continuous vulnerability scanning, manual penetration testing, and the automatic creation of positive security policies within the AppTrana WAAP.
One of its notable benefits is its accessibility to teams that may lack comprehensive API documentation in Swagger and Postman formats. Thanks to the API discovery feature, obtaining Swagger files is seamlessly automated. Additionally, the managed services team plays a crucial role in assisting organizations by assisting with the creation of Postman files for essential open APIs.
Once the apps and APIs are brought under AppTrana’s protection umbrella, they receive immediate, accurate, unified security protection.
AppTrana has default security policies to protect APIs against the OWASP Top 10 API threats. Additionally, based on the risk posture identified through API scans, the API protection profile is continuously updated and fine-tuned. This ensures that any vulnerabilities identified during scans are promptly addressed and patched, leaving no exploitable risk vectors for potential hackers.
Type of protection | AppTrana WAAP | API Gateway |
API Discovery | Available | Not Available |
Positive Security Model | Available | Not Available |
Inbuilt API scanner | Available | Not Available |
OWASP API Top 10 risks | Advanced protection | Weak Protection |
Zero-Day Attack Mitigation | Advanced protection with a low false-positive rate | Weak Protection |
Protection against SSRF, LFI, RFI | Advanced protection | No Protection |
Account takeover | Advanced Protection | Weak Protection |
DDoS protection | Advanced Protection | Supported |
Bot Mitigation | Advanced Protection | No Protection |
Stay tuned for more relevant and interesting security articles. Follow Indusface on Facebook, Twitter, and LinkedIn.
The post What is an API Gateway? – Definition, Benefits and Limitations appeared first on Indusface.
*** This is a Security Bloggers Network syndicated blog from Indusface authored by Vinugayathri Chinnasamy. Read the original post at: https://www.indusface.com/blog/api-gateway/