Protect APIs on Kong Konnect with Choreo Identity & Access Management
This guide explains how to secure your APIs at the Kong Konnect gateway layer using tokens issued by Choreo Identity & Access Management. By retrieving public signing keys from the Choreo Identity & Access Management JWKS endpoint, Kong cryptographically verifies every incoming token at the edge before forwarding authorized requests to your backend services.
The guide covers two core integration approaches available in Kong Konnect:
- Token Validation: Configure Kong to validate incoming JWTs issued by Choreo Identity & Access Management using the OpenID Connect plugin, ensuring only authenticated requests access your APIs.
- Scope-Based Authorization: Leverage Choreo Identity & Access Management's RBAC capabilities to enforce strict, Kong-driven access control policies on upstream APIs.
Prerequisites
- Access to a Choreo Identity & Access Management tenant.
- A Kong Konnect account. The OpenID Connect plugin is available on Konnect-managed data planes.
- Docker is installed on your machine (required to run the Konnect data plane).
curlandjqare available in your terminal.
Configure JWT Token Validation in Kong Konnect
JWT authentication is the foundation of API security with Kong Konnect and Choreo Identity & Access Management. In this section, you register an application in Choreo Identity & Access Management to obtain credentials, configure Kong to validate tokens using Choreo Identity & Access Management's discovery endpoint and JWKS, and verify that unauthenticated requests are rejected.
Configure Choreo Identity & Access Management
Create an Application
- Sign in to the Choreo Identity & Access Management Console at https://console.cloud.choreolabs.com/iam/.
- Navigate to Applications → New Application.
- Enter an Application name (for example,
kong-api-client). - Select Backend service as the application type.
- Click Create application.
- Note the application ID (
<APP_ID>), Client ID, and Client secret from the application details page.
Saving a change does not make it live. You author in the control plane, and your users sign in on a separate data plane, so a change takes effect in an environment only after you deploy it. Go to Deploy, deploy the latest version to your first environment, then promote it to the next environment when you are ready.
Auto-sync deploys saved changes to your first environment within seconds. Turning it on is your choice, per project. See Deploy a Version, or learn why you deploy and how auto-sync works.
Obtain an Access Token
Use the client credentials grant to request an access token:
curl --location 'https://<DATA_PLANE_URL>/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id=<CLIENT_ID>' \
--data-urlencode 'client_secret=<CLIENT_SECRET>'
The response contains an access_token:
{
"access_token": "<ACCESS_TOKEN>",
"token_type": "Bearer",
"expires_in": 3600
}
The token is a JWT signed with RS256. Its iss claim is https://<DATA_PLANE_URL>, which matches the issuer you configure on the plugin. Copy the access_token value. You will use it to call the protected route.
Configure Kong Konnect
Create a Control Plane and Data Plane
-
Sign in to Kong Konnect.
-
Open Gateway Manager and create a new Control Plane (for example,
identity-platform-demo). -
Konnect displays a
docker runcommand, pre-filled with your control plane's cluster endpoints and the generated mTLS certificates, to start a data plane node. Copy that command, and add-p 8443:8443so the data plane can proxy HTTPS traffic.The resulting command looks similar to this (use the exact endpoints and certificate values from Konnect):
docker run -d --name kong-dp \-e "KONG_ROLE=data_plane" \-e "KONG_DATABASE=off" \-e "KONG_CLUSTER_MTLS=pki" \-e "KONG_CLUSTER_CONTROL_PLANE=<CP_ENDPOINT>:443" \-e "KONG_CLUSTER_SERVER_NAME=<CP_SERVER_NAME>" \-e "KONG_CLUSTER_TELEMETRY_ENDPOINT=<TELEMETRY_ENDPOINT>:443" \-e "KONG_CLUSTER_TELEMETRY_SERVER_NAME=<TELEMETRY_SERVER_NAME>" \-e "KONG_CLUSTER_CERT=<CLUSTER_CERT>" \-e "KONG_CLUSTER_CERT_KEY=<CLUSTER_CERT_KEY>" \-e "KONG_LUA_SSL_TRUSTED_CERTIFICATE=system" \-e "KONG_KONNECT_MODE=on" \-e "KONG_PROXY_LISTEN=0.0.0.0:8443 ssl" \-p 8443:8443 \kong/kong-gateway:3.9 -
Wait until the data plane shows as Connected in the Konnect Gateway Manager.
Create a Service and Route
- In Gateway Manager, open your control plane and go to Services → Add Service.
- Enter a name (for example,
bookings) and set the URL to your upstream bookings API (for example,https://<BOOKINGS_API>). - Open the new service, go to Routes → Add Route, and add a route with the path
/bookings.
Add JWT validation
Attach the plugin to the route so it validates every incoming token.
-
Open the
/bookingsroute and go to Plugins → Add Plugin. -
Select OpenID Connect.
-
Configure these parameters:
Parameter Value issuerhttps://<DATA_PLANE_URL>/.well-known/openid-configurationclient_id<CLIENT_ID>client_secret<CLIENT_SECRET>client_authclient_secret_postauth_methodsbearerbearer_token_param_typeheader -
Save the plugin.
With issuer set, the plugin fetches Choreo Identity & Access Management's JWKS from the discovery document and verifies each token's signature, issuer, and expiry by default. Restricting auth_methods to bearer makes the plugin validate the incoming access token only, without initiating a login flow. Setting bearer_token_param_type to header makes the plugin read the token from the Authorization: Bearer <token> header used in the examples below.
Try It Out
Request without a token, expect 401 Unauthorized:
curl -k -i "https://127.0.0.1:8443/bookings"
Request with a valid Choreo Identity & Access Management token, expect 200 OK:
export ACCESS_TOKEN="<ACCESS_TOKEN>"
curl -k -i "https://127.0.0.1:8443/bookings" \
-H "Authorization: Bearer $ACCESS_TOKEN"
A successful request returns an HTTP 200 response forwarded from the upstream. If the token is missing, invalid, or expired, Kong returns 401 Unauthorized.
Configure Scope-Based Authorization in Kong Konnect
JWT validation confirms that a token is valid and was issued by Choreo Identity & Access Management. It does not control what the token holder is allowed to do. With the configuration from the previous section, Kong accepts any valid Choreo Identity & Access Management token regardless of the application or its assigned permissions.
Scope-based authorization adds a second layer of control. Choreo Identity & Access Management embeds scopes in tokens based on the roles assigned to an application. Kong then checks those scopes on every request and rejects tokens that do not carry the required permissions. To enforce that tokens carry specific permission scopes, configure the OpenID Connect plugin's scopes_required parameter.
The steps below build on the JWT validation configuration from the previous section. You will define a Resource Server, a Resource, and actions in Choreo Identity & Access Management to model your API permissions. Then bundle them into a role, assign the role to your application, and update the Kong plugin configuration to enforce scope validation.
Configure Choreo Identity & Access Management
Create a Resource Server
A Resource Server represents your API in Choreo Identity & Access Management. It groups the resources and actions that model your API, and exposes a permission (scope) for each action.
- In the Console, navigate to Resource servers → Add resource server.
- For the type, select API.
- Enter a Resource server name (for example,
Bookings API) and an Identifier (for example,https://bookings.example.com). - For the Permission delimiter, select
:. - Select the Organization the resource server belongs to, then create it.
Add Resources and Actions
A Resource represents an entity within the API (such as the /bookings route), and Actions define the operations allowed on it. Each action produces a scope in the format <resource-handle>:<action-handle>.
- Open the resource server you just created and go to the Resources & actions tab.
- Click Add resource and enter a Name (for example,
Bookings) and a Handle (bookings). - Under that resource, click Add action and enter a Name (for example,
Read Bookings) and a Handle (read). - Add a second action with a Name (for example,
Write Bookings) and a Handle (write).
This produces the permissions bookings:read and bookings:write, which Choreo Identity & Access Management includes in tokens issued to applications that hold a role granting them.
Create a Role and assign permission
Roles bundle one or more permissions together. Assigning a role to an application controls which scopes appear in its tokens.
- Navigate to Roles → Add role.
- Enter a Role name (for example,
Bookings manager). - Click Continue.
- Under Assign permissions, choose
bookings:read. - Click Continue.
Assign the Role to the Application
Assign the role to the application you created in the previous section. Choreo Identity & Access Management includes the role's scopes in every token issued for that application.
- Open the role and go to the Assignments tab.
- Under Apps, assign the application you created earlier (
kong-api-client).
Configure Kong Konnect
Update the OpenID Connect plugin on your /bookings route to require the generated scope:
-
Open the route's OpenID Connect plugin configuration.
-
Set the following parameter:
Parameter Value scopes_requiredbookings:read -
Save the plugin.
The plugin reads scopes from the scope claim (the default scopes_claim) and rejects any token missing bookings:read with 403 Forbidden, before the request reaches your upstream.
To restrict tokens to this API, set audience_required to the protected resource server's identifier. Choreo Identity & Access Management uses that identifier as the access token's aud claim, which the plugin reads from the default audience_claim (aud).
Try It Out
Obtain an Access Token with the Required Scope
Request a token for the application that has the role assigned:
curl --location 'https://<DATA_PLANE_URL>/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'scope=bookings:read' \
--data-urlencode 'client_id=<CLIENT_ID>' \
--data-urlencode 'client_secret=<CLIENT_SECRET>'
The response confirms the scope is present:
{
"access_token": "<ACCESS_TOKEN>",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "bookings:read"
}
Call the Protected API
With a token that has the required scope, the request is forwarded to the upstream:
export ACCESS_TOKEN="<ACCESS_TOKEN>"
curl -k -i "https://127.0.0.1:8443/bookings" \
-H "Authorization: Bearer $ACCESS_TOKEN"
Kong verifies the token carries the bookings:read scope and forwards the request to your upstream bookings API.
With a token missing the required scope, expect 403 Forbidden:
curl -k -i "https://127.0.0.1:8443/bookings" \
-H "Authorization: Bearer <TOKEN_WITHOUT_REQUIRED_SCOPE>"
Kong inspects the token, finds the bookings:read scope absent, and returns 403 Forbidden.
Plugin Parameter Reference
| Parameter | Value | Description |
|---|---|---|
issuer | https://<DATA_PLANE_URL>/.well-known/openid-configuration | Choreo Identity & Access Management's discovery endpoint. The plugin fetches the JWKS from here and verifies each token's signature, issuer, and expiry. |
client_id | <CLIENT_ID> | Client ID of the Choreo Identity & Access Management Backend Service application. |
client_secret | <CLIENT_SECRET> | Client secret of the Choreo Identity & Access Management Backend Service application. |
client_auth | client_secret_post | Sends plugin client credentials in the request body when the plugin calls Choreo Identity & Access Management endpoints. |
auth_methods | bearer | Restricts the plugin to validating the incoming bearer access token, without starting a login flow. |
bearer_token_param_type | header | Reads the bearer token from the Authorization header. |
scopes_required | bookings:read | Scopes the token must carry. Missing scopes are rejected with 403. Omit to accept any valid token. |
scopes_claim | scope | The token claim the plugin reads scopes from. Choreo Identity & Access Management emits resource scopes in the scope claim. |
audience_required | <RESOURCE_SERVER_IDENTIFIER> | Optional. Audience the token must carry. Set it to the identifier of the resource server that protects this API. |
audience_claim | aud | The token claim the plugin reads the audience from. |
Was this page helpful?