API packages are composed from operations. Operations allow you to compose REST-style APIs from a combination of the hostname, path, and method that are processed by the control plane. They are used to map between the operations in your API and Gateway Routes. If an OpenAPI spec is added to the API, the operations are autogenerated.
The following diagram shows an example of how API packages can be composed from operations:
flowchart LR
subgraph subGraph0["Control plane"]
1["Billing Gateway Service"]
2["Flights Gateway Service"]
end
subgraph subGraph1["Partners API package"]
3["POST /flights"]
4["GET /flights"]
end
subgraph subGraph2["Org API package"]
5["POST /billing"]
6["GET /billing"]
7["POST /flights"]
8["GET /flights"]
end
1 --> 5 & 6
2 --> 7 & 8 & 3 & 4
Packaging APIs involves the following steps:
- Create an API and attach an OpenAPI spec. Operations from your API’s OpenAPI spec should overlap with Routes to ensure requests will be routed to the correct Service. Gateway routing configuration isn’t directly modified by adding operations.
- Link a control plane to allow developer consumption.
- Apply the Access Control Enforcement (ACE) plugin globally.
- Create an API package by adding operations and package rate limits. Operations are automatically mapped to Routes using your API’s OpenAPI spec or you can create them manually. The Gateway configuration isn’t directly modified – any unmatched operations will be highlighted to indicate that a user needs Gateway Manager permissions needs to perform an action.
The Access Control Enforcement (ACE) plugin manages developer access control to APIs published with Dev Portal.
Previously, when you created an API catalog in Dev Portal and linked the APIs to a Gateway Service, Konnect would automatically apply the Konnect application auth (KAA) plugin.
API packages use the ACE plugin instead to manage developer access control to APIs. Unlike the KAA plugin, the ACE plugin can link to control planes to configure access control and create operations for Gateway Services.
The ACE plugin runs after all other authentication plugins run.
For example, if you have Key Authentication configured and it rejects a request, the ACE plugin will not run.
To allow for multiple authentication plugins, each one must set the config.anonymous plugin configuration.
Additionally, the choice to allow or reject an anonymous result after all authentication plugins have run needs to be controlled as described in using multiple authentication methods.
When you configure the ACE plugin, you must set either required or present for config.match_policy. This determines how the ACE plugin will behave when a request doesn’t match an existing Route.
Keep in mind that misconfigurations can overexpose unintended Routes.
The following table describes what the match_policy values do and when to use each:
|
Setting
|
Description
|
Limitations
|
Use cases
|
required
|
Requires every incoming request to match a defined operation from an API or API package in Dev Portal. If a request doesn’t match, ACE rejects the request outright with a 404. All traffic will be rejected except operations or Routes in published APIs linked to an ACE-enabled Kong Gateway.
Warning: Setting the match_policy to required can block all traffic with a 404. Any undefined endpoints will be blocked. If you accidentally enable this in your control planes, this could cause a potential outage in production.
|
- Shuts down all traffic outside of ACE-enabled Dev Portal APIs.
- If the plugin is improperly configured, potentially all traffic could be terminated.
|
- You want to lock down Konnect so that only traffic that is part of an explicitly defined API operation is allowed through.
- You only plan to provide self-service access via your Dev Portal.
|
if_present
|
By default, the ACE plugin only engages with a request when it matches an operation. If a request doesn’t match, ACE lets the request pass through untouched. This means that non-matching requests aren’t rejected, but ACE also won’t perform authentication and authorization on them. This allows a request to still be processed by other plugins with a lower priority than ACE.
|
- All traffic outside of published APIs linked to an ACE-enabled Kong Gateway won’t be access controlled; this must be configured with a different authentication plugin. Dev Portal will not be able to protect all operations.
- Since Routes aren’t protected by default in this mode, any mistyped or omitted operation in API entities could result in open access.
|
- You have an environment where some Gateway Services or Routes are governed by Dev Portal–exposed APIs (with ACE), while others are regular Routes that should be left alone.
- You already have existing traffic and other access controls in place and want to avoid interruption.
|
You can set individual rate limits on an API package as well as operations in that package. Keep the following in mind when configuring rate limits:
- API package rate limits apply across all operations in the API package cumulatively, not individually.
- Each operation in an API Package can additionally have an individual rate limit defined. When an operation-level override is present, the package-level limit is ignored for that operation.
- API package rate limits are applied simultaneously with rate limits from other plugins on gateway entities:
- Requests that are under the current limit for the Service and API Package will be counted towards both.
- Requests that surpass the rate limit of an API package won’t be counted towards rate limits applied from other rate limiting plugins.
- Requests that surpass the rate limit of other rate limiting plugins are still counted towards the rate limits applied for API packages. This is because the ACE plugin runs before other rate limiting plugins under the default plugin priorities. You can adjust this behavior with custom plugin priority values.
- Rate limiting is applied per credential.
For example, if you have the following rate limits set:
-
API package A: 10 requests per second
-
Operation 1: 5 requests per second
Because an operation-level override is present, the package-level limit is ignored for that operation. This means a request authorized for Operation 1 will only count toward its specific operation-level limit. So, if one request is sent, the authorized application will have four requests remaining for Operation 1 for the configured time period (per second). The package-level limit of API Package A doesn’t apply to this request.
When configuring API packages, keep the following limitations in mind:
- If you have two endpoints in your spec, one with a trailing slash and one without, both are generated as the same operation.
- If two operations have the same path and method, they are generated as the same operation.
- All operations for a control plane are removed when you unlink the control plane.
- APIs can only be mapped to one control plane at a time.
- You can’t change a version or edit a spec for an API if it would remove an operation because this would result in a breaking change. To remove an operation, we recommend unlinking the control plane from the API.