Keycloak and Apache APISIX API authentication

Protecting APIs at the gateway means deciding which callers get tokens, where validation happens and who maintains the Keycloak clients. This page explains how the APISIX openid-connect plugin fits with Keycloak and what the work involves.

On this page

Keycloak and Apache APISIX API authentication: what the gateway checks

The APISIX openid-connect plugin either validates tokens issued by a Keycloak realm or obtains tokens from that realm on a client's behalf, and making it work takes three pieces configured together: the APISIX routes that carry the plugin, the Keycloak clients that represent each route or caller, and the token checks that decide which requests reach an upstream service. A team whose APIs already sit behind APISIX and who need Keycloak-issued tokens verified before traffic reaches those services should plan all three as one design, not as separate tickets. The plugin supports the authorization code, client credentials, token introspection and PKCE flows. Which one fits depends on who is calling the API. Browser-based and user-facing traffic usually goes through the authorization code flow, often with PKCE, while machine-to-machine calls typically use client credentials. Token introspection asks Keycloak whether a presented token is still active, which matters when you need revocation to take effect quickly. Decide the caller types first, then map each route to one flow, because a single route that accepts every flow is harder to reason about and to test. APISIX and Keycloak are both self-hosted, so the gateway, the identity provider and the network paths between them stay in the infrastructure you control. The plugin is not limited to Keycloak. The APISIX documentation also lists Auth0, Microsoft Entra ID, Google and Okta as identity providers it works with, so the configuration pattern you build here carries over if your identity provider changes. Confirm the exact settings for your APISIX version against the plugin documentation before you rely on them. The integration is configured per route. Each route that needs protection carries its own openid-connect settings, including the discovery endpoint of the Keycloak realm, the client identifier and secret, and the redirect or introspection behavior. No connector is required beyond the documented plugin, so the work is configuration, testing and operations rather than custom code. Teams should still confirm which routes need authentication, which can stay public, and how unauthenticated requests should respond. Before you go live, check what the gateway actually enforces. Send requests with no token, an expired token, a token from a different realm and a token issued to a client that should not reach that route, and confirm each one is rejected at APISIX rather than at the upstream service. Also verify that the claims the upstream relies on are passed through as intended. These checks define what the gateway checks, and they should be written down and repeated after each APISIX or Keycloak upgrade.

What you need in place before configuring APISIX and Keycloak

Both products need decisions made before any route or plugin is configured. Confirm each item below in writing and assign an owner, so the gateway and identity provider are built against the same versions, names and trust settings.

Supported APISIX release

Confirm the current 3.x release on the Apache APISIX downloads page before you choose a version. That page listed 3.19.0 as released September 28, 2026, and it marks no release as long-term support. Decide which release line your team will maintain, how it will take patch releases, and who tests each upgrade against the openid-connect plugin behavior you depend on.

Deployment mode decision

Choose traditional, decoupled or standalone mode before anything else, because the mode determines where configuration lives. Traditional mode runs data and control planes together, listening on port 9080 for client traffic and port 9180 for the Admin API. Decoupled mode shares one etcd cluster between planes, while standalone mode reads conf/apisix.yaml or conf/apisix.json and checks for changes every second. Name the team that will own etcd or the configuration files.

Keycloak release and database

Pick the Keycloak release you will run and check it against the Keycloak documentation. The current release is 26.8.1, published October 13, 2026. Keycloak lists PostgreSQL 14 to 18 among its supported production databases, and the default dev-file database is for development only. Confirm the database version, backup method, and whether schema migration runs at startup or is applied manually.

Realm and DNS names

Create a dedicated realm for the APIs and decide the public hostnames for the gateway and the identity provider. Keycloak's production guide recommends exposing the admin console and Administration REST API on a different hostname or context path from public frontend URLs, so plan that split now. Record the issuer URL exactly, because token validation compares it with the issuer in each token, and define the clients the gateway will use.

Certificates and network reachability

APISIX must trust the certificate chain Keycloak presents for every endpoint it calls, including discovery, JWKS and token endpoints. Keycloak's production guide calls for TLS on all communication, so distribute your internal certificate authority to each gateway host. Confirm the network path from every APISIX node to the issuer and token endpoints, including proxy and firewall rules, and test it from the same host or container image the gateway runs on.

Owners and test upstream

Name one owner for the APISIX configuration, one for the Keycloak realm and clients, and one for network and certificates, with an agreed escalation path between them. Prepare a test upstream service that echoes the request headers it receives, so you can confirm which token claims reach the backend. Use an endpoint you control that does not carry production traffic, and agree in advance who approves changes to client secrets.

Which Keycloak token flow fits each caller behind APISIX

The first architecture decision for Keycloak behind APISIX is not which plugin to install but which token flow each caller uses. Three caller types usually appear in one API estate: browser users, backend services and clients that hold opaque or reference tokens. Each maps to a different OAuth 2.0 flow in Keycloak, and each asks APISIX to do a different job. Settling this mapping first keeps the gateway configuration small and makes the trust boundaries visible to reviewers. Browser users should sign in through the authorization code flow. Keycloak issues a code after the user authenticates, and the gateway exchanges that code for tokens on the server side, so the access token never has to be handled by page script. Where the browser application is a public client with no secret it can hold, PKCE must be enabled on the Keycloak client so the code exchange is bound to the original request. In this pattern APISIX redirects unauthenticated users to Keycloak, receives the callback, exchanges the code and manages the session. Decide early whether APISIX holds the session cookie or whether the application does, because that choice changes logout, token refresh and what the upstream service sees.

Services that call APIs on their own behalf should use the client credentials flow. There is no user, so the Keycloak client should be confidential, with a secret or a certificate-based client authentication method held in your secrets store, and its service account should carry only the roles that the target API needs. APISIX's role in this flow is to validate the bearer token it receives, not to request one. Plan for token lifetime and rotation on the calling side, since the caller, not the gateway, obtains and refreshes these tokens. Clients that present opaque or reference tokens need token introspection. In this case APISIX does not decode the token locally. It calls the Keycloak introspection endpoint with its own client credentials and accepts the request only when Keycloak reports the token as active. The trade-off is clear: revocation is seen on the next check, but every protected request adds a network call and a dependency on Keycloak availability, so caching behavior and timeouts must be sized before go-live. Confirm in the openid-connect plugin documentation for your APISIX version which options govern introspection, caching, bearer token handling and which flows are supported, because option names and defaults change between releases. Your architecture team should record that confirmation with the chosen version in the design document.

How to configure the APISIX openid-connect plugin for a Keycloak realm

This sequence takes a Keycloak realm and a test route in Apache APISIX from empty configuration to a gateway that redirects anonymous browser users to sign in and rejects unauthenticated API calls. It ends with a promotion path that moves the same route definition through each environment. Exact attribute names come from the openid-connect plugin page for the APISIX version you install.

  1. Create the realm and confidential clients

    A Keycloak administrator creates a dedicated realm for the API estate, then creates two confidential clients. The first client is for the gateway, which exchanges authorization codes and holds a client secret. The second is for machine callers that use the client credentials grant, with a service account and only the roles it needs. Store each secret in your secrets manager and keep it out of route files. Done when both clients appear in the realm with client authentication turned on and the test users or service account roles are assigned.

  2. Set redirect URIs and scopes

    In the gateway client, register the exact callback URL that APISIX will serve for the test route, using the HTTPS hostname of your gateway. Limit valid redirect URIs to that value and check the redirect_uri setting on the plugin page for your version. Set the scopes the route needs, such as openid and profile, and confirm that the machine client receives only the scopes its job requires. Done when a test login reaches the callback path without a redirect URI error and the token shows the expected scope values.

  3. Confirm the discovery document is reachable

    From the APISIX host or container, request the issuer's OpenID discovery document at the well-known path for the realm. Confirm it returns JSON with the issuer, authorization, token and JWKS endpoints. Check that the issuer value matches the iss claim Keycloak puts in tokens, including the hostname and realm path, because a mismatch causes validation failures later. Done when the request succeeds from the gateway's own network and the TLS chain validates against the CA bundle APISIX uses.

  4. Add the openid-connect plugin to a test route

    Create a test route in APISIX through the Admin API or your configuration file, with an upstream that echoes request headers, and attach the openid-connect plugin. Set the client ID, client secret, discovery URL and the flow you chose: authorization code for browser sessions, or the bearer token options for API callers. Attribute names differ between versions, so take each one from the openid-connect plugin page for the APISIX release you installed before writing the route. Done when APISIX accepts the configuration without a schema error and the route appears in the admin listing.

  5. Send an unauthenticated request

    Call the test route with no session cookie and no bearer token. For a browser-style request, expect a redirect to the Keycloak login page. For a request that sends a JSON Accept header or no browser context, expect a 401 response. Confirm which behavior applies against the unauthenticated settings on the plugin page for your version. Done when the response is one of those two outcomes and the upstream access log shows that the upstream received no request.

  6. Send an authenticated request and inspect headers

    Sign in through the browser flow, or obtain an access token for a test user, then call the same route with the session or bearer token. Confirm that the upstream echo shows the identity headers and claims you configured for the plugin, using the header names listed on the plugin page for your version. Done when the request returns the upstream response and the echoed values match the claims in the test user's token. Record this output as the baseline for later comparisons.

  7. Add introspection-based validation for opaque tokens

    Where machine callers send tokens that APISIX must validate against Keycloak on each request, switch the plugin to token introspection. Point it at the introspection endpoint of the realm and authenticate with the gateway client. Introspection adds a call to Keycloak for each validation, so measure its effect in a test environment. Decide whether the gateway should cache introspection results and for how long, using the caching settings on the plugin page. Done when a revoked or expired test token is rejected and a valid token is accepted.

  8. Enable PKCE and promote the route

    Turn on PKCE in the plugin for browser and native flows, and set the matching client configuration in Keycloak so the client requires PKCE on the authorization code flow. Store the route definition in version control, replace environment-specific values such as hostnames, realm names and secrets with variables, and promote it in order through development, test and production. Repeat the unauthenticated and authenticated checks in each environment. Done when each environment returns the same results as the earlier checks and the production route contains no test-only settings.

Which token claims and client settings map to gateway behavior

This table maps each Keycloak realm setting, client setting and token claim to the APISIX openid-connect plugin behavior it controls. Read each row as a question to answer during design: which Keycloak value the gateway depends on, and what the gateway does with it at request time. Claim names depend on the Keycloak client mapper configuration, so confirm each one in the client's token preview before writing route rules.

Keycloak itemAPISIX behaviorWhat to confirm
Realm issuer URLUsed as the discovery endpoint for the openid-connect plugin, which loads the issuer's OpenID configuration and signing keysThe issuer URL in the plugin matches the iss claim in the tokens exactly, including hostname and realm path
Confidential client ID and secretStored in the plugin client configuration and used to authenticate the gateway to Keycloak during code exchange and introspectionThe client has client authentication enabled, and the secret is held in a secrets store rather than in route files
Requested scopesDetermine which claims and audience values appear in the access token that the gateway receives and forwardsThe aud claim includes the API audience, and the scopes requested by the gateway match the client scope mappers
sub claimTypically used as the stable subject identifier passed upstream in a header for the backend to key user recordsThe mapper emits sub unchanged, and the upstream service does not depend on usernames for identity
preferred_username claimCan be passed upstream as a header for display or audit logging when the plugin is configured to forward user infoThe claim is present in the token preview, since it depends on the profile mapper being enabled on the client
email claimCan be forwarded upstream as a header when the plugin is set to pass user information, useful for applications that expect an addressThe email mapper is enabled and the email is verified in Keycloak, because unverified addresses should not drive authorization
groups claimForwarded as a header or read by route logic for coarse access decisions, if a group mapper is configured on the clientThe group mapper is added to the client, and the claim name and format match what the plugin and backend expect
Access token and refresh token lifetimesControl how long the gateway session cookie and token refresh cycle remain valid when the plugin manages sessionsLifetimes in the realm and client settings are set deliberately, and the gateway session timeout is aligned with them
Client rolesCan be read from the token and compared with route-level rules that permit or deny specific API operationsRoles are mapped into the token by a client role mapper, and the role names match those referenced in the gateway configuration
Realm rolesCan be checked at route level in the same way as client roles when the token contains a realm_access claimThe realm role mapper is enabled, and the claim path used by the route check is confirmed in the token preview

Where Keycloak authorization fits behind the API gateway

APISIX is well suited to authenticating callers at the edge: the openid-connect plugin can verify a Keycloak-issued token before a request reaches an upstream, and route-level rules can reject requests that lack the expected identity. Fine-grained decisions are a separate design question. Keycloak's fine-grained authorization services model resources, scopes and policies, and those objects are evaluated by Keycloak or by a component that calls Keycloak, not by the gateway on its own. Treat the gateway as the place where coarse admission is enforced and treat resource-level permissions as a decision you make explicitly, rather than assuming the gateway will cover it.

A common pattern is for APISIX to validate the token and forward it upstream, after which each service validates the same token against Keycloak. The service checks the signature against the realm's published keys, confirms the issuer, audience and expiry, and then reads claims such as roles or groups. Where the service needs a live answer, it can call the Keycloak token endpoint or the introspection endpoint for the token. Decide early whether the upstream trusts the gateway's verification or repeats it. Repeating it costs a little latency and some key management, but it means a misconfigured route cannot quietly expose a service that trusts whatever arrives.

Role or group claims are the usual input for route rules. A realm or client role mapper can place roles into the access token, and the gateway configuration can then require a specific role for a path prefix or HTTP method. This works well for a small number of stable roles, such as a reader and a writer for an API family. It becomes hard to maintain when rules multiply, when roles mix business meaning with technical meaning, or when group membership changes faster than tokens expire. Keep the claim names, their mapping sources and their owners in a written access model before writing route rules, and test that a removed role stops working at the expected point in the token lifecycle.

Centralizing decisions at the gateway gives one place to review and change access for many services, and it keeps service code simpler. The cost is that the gateway becomes a single point of policy, its configuration must be versioned and tested like application code, and application owners may not see why a request was denied. Keeping decisions in each service keeps authorization close to the data it protects and to the people who understand it, but it spreads rules across teams and languages, which makes consistent audit evidence harder. Many organizations settle on coarse checks at the gateway and resource-level checks in services, and document which party owns each rule.

Before promising a model to auditors or application owners, confirm which authorization checks your gateway configuration can express for the APISIX version you deploy. The current APISIX release line and its plugin options change over time, so check the openid-connect plugin documentation and your own test results for claim matching, method-based rules and any consumer or role controls you intend to rely on. Run a negative test for each rule, including an expired token, a token missing the required role and a token for a different client. Record the results as the evidence for the model, and state clearly which decisions remain in the services.

Security settings for protecting APIs with Keycloak tokens

Protecting APIs with Keycloak tokens at Apache APISIX depends on settings spread across the identity provider, the gateway and the network between them. The cards below cover the controls that matter most for this integration, from transport security and secret storage to token lifetimes and monitoring. Each control should be mapped to your own security policy before it is adopted.

TLS on issuer, token and gateway

Serve the Keycloak issuer, token endpoint and APISIX client listeners over TLS, and keep the issuer URL that the gateway validates identical to the one Keycloak publishes. Keycloak's production guide calls for TLS on all communication, so confirm certificate chains are trusted by the gateway and by any backchannel introspection calls. Mismatched hostnames or internal-only certificates are a common cause of failed token validation.

Client secrets outside route files

Confidential clients used by the openid-connect plugin need a client secret, and that secret should live in a secrets manager rather than in APISIX route definitions or version control. Check how your APISIX deployment mode loads configuration, since route files and the Admin API both expose plugin configuration to anyone who can read them. Plan rotation and confirm who can read the secret store.

Least-privilege client scopes

Assign each APISIX client only the client scopes and roles its routes need, and remove default scopes that add claims the gateway does not use. Review which audiences and roles appear in issued access tokens for each route group. A client that can request broad scopes widens the impact of a leaked token or a misconfigured route.

Short token lifetimes and refresh policy

Set access token lifetimes short enough that a stolen token has limited use, and define how refresh tokens are issued, rotated and revoked for browser-based flows. Document the session idle and maximum limits in Keycloak and confirm how the openid-connect plugin behaves when a token expires mid-session. Test expiry on each route type before go-live.

PKCE for public clients

Require PKCE for any public client, such as a single-page application or a native app that starts an authorization code flow through APISIX. Public clients cannot keep a secret, so PKCE is the control that binds the code exchange to the original requester. Confirm the openid-connect plugin configuration enables PKCE for those routes and that Keycloak enforces it on the client.

Restricted Admin API and console exposure

In traditional mode APISIX serves its Admin API on port 9180, separate from client traffic on port 9080, so restrict that port to management networks and never publish it to the internet. Keycloak's production guide advises exposing the admin console and Administration REST API on a different hostname or context path from public frontend URLs. Verify both with a network scan from outside your management zone.

Audience and issuer validation

Configure the gateway to check the token issuer and audience on every protected route, not only signature validity. Confirm the expected audience matches the client the route serves, and that tokens minted for another API are rejected. Test with tokens from a different client in the same realm, because that is the case validation most often misses.

Rejected token logging and metrics

Log rejected tokens at the gateway with enough context to investigate, such as the route, client, reason and timestamp, while keeping raw tokens out of logs. Enable Keycloak metrics with --metrics-enabled=true so Prometheus-format data is served at /metrics on the management interface, and restrict access to that endpoint. Alert on spikes in failed logins and token errors, and confirm retention meets your log policy.

How to test that the gateway enforces Keycloak tokens

The gateway is only protecting your APIs if it refuses the requests it should refuse, accepts the ones it should accept, and keeps its own management plane out of reach. Treat the test plan as an acceptance gate for the Keycloak and Apache APISIX design, not as a one-time smoke check. Each test below should have a named expected result, a recorded input, and an owner who can explain a failure. Negative token tests Start with requests the gateway must reject. Send a request with no token, an expired access token, a token whose audience does not match the API's expected audience, and a token issued by a different realm or issuer URL. Confirm the status code returned to the client and confirm that the upstream service never received the request. For the audience and issuer cases, check the configuration in the openid-connect plugin and in the Keycloak client scopes, because a mismatch in either place can produce a rejection that looks correct but is caused by a broken setting. Also test a token signed by a key that Keycloak no longer publishes.

Positive tests should cover each flow you intend to support: authorization code for user-facing applications, client credentials for service-to-service calls, and token introspection where you have chosen it. Use a real client registration for each flow, not a shared test account. Confirm the claims the upstream receives match what the route is meant to expose, and that scopes or roles that were not granted are absent. Record the token type, client ID, and expiry used in each test so the evidence can be traced back to a Keycloak client. Management plane and forwarded headers From each client network segment, attempt to reach the APISIX Admin API and the metrics or management endpoints of Keycloak. In traditional mode the Admin API listens on port 9180, so confirm which networks can reach that port and that the answer is a refusal, not just a missing route. Confirm the same for Keycloak's admin console and Administration REST API, which the production guide says should sit on a different hostname or context path from public frontend URLs. At the upstream, verify that forwarded headers such as the client address and protocol are set by the gateway and cannot be spoofed by a client request. Failover, restart and key rotation Restart the gateway nodes and, in the chosen deployment mode, the etcd members, while sending steady test traffic. Record which requests fail, for how long, and whether authorization decisions remain consistent once the component returns. Then rehearse a Keycloak signing key rotation in a non-production realm: publish the new key, confirm the gateway picks it up, retire the old key, and confirm that tokens signed with the retired key are rejected. Confirm with your Keycloak version and the APISIX openid-connect plugin documentation how key discovery and caching behave before you set a rotation window. Evidence and separate security testing Keep the results as dated evidence: the test plan, inputs, outputs, configuration versions, and sign-off. Change management teams usually need this record for each release of the gateway or Keycloak, and security reviewers use the same record as a baseline. The tests above confirm expected behavior. They do not establish that an attacker cannot bypass the gateway, so a separate security test of the gateway and its routes is a different piece of work. DeployOpen can run that security testing as a separate engagement with its own written scope.

Common Keycloak and APISIX failures and how to fix them

This table lists the failures teams most often hit when APISIX validates Keycloak tokens, with the likely cause, what to check first and the fix for each. Work down the rows in order when a request is rejected, because the first check in most rows exposes the cause quickly. Exact log messages vary by APISIX and Keycloak version, so confirm them in your own environment before you rely on any match.

FailureLikely causeCheck firstFix
Redirect URI mismatch in KeycloakThe redirect URI APISIX sends during the authorization code flow does not exactly match a valid redirect URI on the Keycloak client, including scheme, host, port and path.Compare the redirect_uri parameter in the browser's authorization request with the client's Valid redirect URIs in Keycloak.Add the exact callback URL APISIX uses to the client's valid redirect URIs, and avoid broad wildcards in production.
Discovery URL unreachable from APISIXAPISIX cannot reach the realm's OpenID discovery document (.well-known/openid-configuration) because of DNS, routing or firewall rules between the gateway and Keycloak.Run a request to the discovery URL from the APISIX container or host, and confirm the name resolves to the expected address.Fix DNS or routing from the gateway network to Keycloak, and allow outbound access on the Keycloak port for the gateway only.
Discovery fails on an untrusted certificateKeycloak serves TLS with a certificate issued by an internal CA that APISIX does not trust, or the chain is incomplete.Check the certificate chain presented by Keycloak and whether the CA bundle used by APISIX includes the issuing CA.Install the internal CA in the trust store APISIX uses and serve the full certificate chain from Keycloak. Do not disable verification to get past the error.
Issuer mismatch caused by a proxy hostnameThe iss claim in the token reflects the public hostname Keycloak uses, but APISIX is configured with an internal hostname (or the reverse), so the values differ.Decode a token and compare its iss value with the issuer in the discovery document and the issuer configured in the route.Set the Keycloak hostname and proxy settings so the issuer is consistent, then point the APISIX configuration at that same issuer value.
Clock skew causing token rejectionThe gateway and Keycloak hosts disagree on the time, so tokens appear expired or not yet valid to APISIX.Compare the system time and NTP sync state on the gateway nodes and the Keycloak nodes, then check the token's iat, nbf and exp values.Synchronize all nodes with the same time source. Avoid widening validation leeway as a long-term fix.
Client secret rotated in Keycloak but not in the routeThe client secret was regenerated in Keycloak, but the APISIX route still holds the old value, so token exchange or introspection fails.Confirm the client secret in the Keycloak client's Credentials tab and check the route's client_secret setting in APISIX.Update the secret in the route (or in the secret store APISIX reads from), apply the change, and record the rotation in your change process.
Introspection endpoint blocked by network policyThe token introspection endpoint is reachable from a browser but not from the gateway, because a network policy, security group or egress rule blocks the call.Test the introspection URL from the gateway network, and review egress rules and any policy that limits outbound traffic from the gateway.Allow the gateway to reach the introspection endpoint over TLS, and document the rule so it survives infrastructure changes.
Audience not present in the tokenThe access token does not include the audience value the route expects, so APISIX rejects it even though the signature is valid.Decode the access token and check the aud claim against the audience value configured for the route or client.Add an audience mapper to the Keycloak client scope so the expected value appears in the token, and align the route configuration with it.
Upstream receives no identity headersThe token validates, but the claims the upstream needs were not mapped into the headers or userinfo that APISIX forwards.Confirm which claims the openid-connect plugin is configured to pass and whether those claims exist in the token or userinfo response.Add the required protocol mappers in Keycloak, such as user attributes or group membership, and map them to the headers the upstream reads. Confirm behavior against the plugin documentation for your APISIX version.

Questions teams ask before connecting Keycloak to APISIX

What drives the cost and effort of connecting Keycloak to APISIX?

The main drivers are how many APIs and upstreams sit behind the gateway, how many distinct client types you need (browser apps, machine clients, internal services), and how much of the Keycloak side is already configured. Scope drivers: realm and client design, the number of routes that need different token rules, and whether APISIX runs in traditional, decoupled or standalone mode. Testing drivers: how many token scenarios (expired, revoked, wrong audience, missing claims) must be verified and how many environments exist. DeployOpen does not publish a price list. A quote follows from a written scope that lists these items, so ask for each driver to be stated explicitly.

How long does a Keycloak and APISIX authentication project take?

Duration depends on scope rather than on the gateway alone. A single upstream protected by one authorization code flow is a much smaller effort than a platform with many routes, several client types, and token introspection for internal services. The factors that extend timelines most often are unresolved identity decisions (claims, groups, audiences), certificate and network approvals, and the number of environments that must be validated before production. DeployOpen agrees timelines in the written scope before work starts, so ask for the phase breakdown and the assumptions behind each phase.

What must our team provide before the integration work starts?

Plan to provide named owners for both Keycloak and APISIX, along with access to the environments where each runs. You will also need test upstream services that represent the APIs being protected, TLS certificates for the gateway and Keycloak hostnames, and confirmed network paths between the gateway, Keycloak, the etcd or configuration store used by your APISIX mode, and the upstreams. Decide who approves Keycloak client registrations and who can change gateway routes. Missing any of these usually stalls testing rather than design, so confirm each item in the scope document with your own infrastructure and security teams.

Can an internal team do this integration without a partner?

Yes, a team with experience in OpenID Connect and in APISIX administration can build this, and many do. The questions to answer honestly are whether you have someone who understands token validation, PKCE, and audience checks, whether that person can own both systems after go-live, and whether you have test capacity for the failure cases. A partner is most useful when the same engineers cannot cover the design review, the security testing and the operational handover at the same time. Compare your own skills against the build sequence and the verification steps in the scope before deciding.

Which Keycloak flow should we pick for APIs behind APISIX?

Choose by who is calling the API. Authorization code (with PKCE where supported) fits browser and single-page applications where a user signs in. Client credentials fits service-to-service calls with no user present. Token introspection fits cases where the gateway must ask Keycloak whether a token is still active, which trades extra load and latency for immediate revocation checks. Many platforms use more than one flow, with separate routes or plugin settings for each. The APISIX openid-connect plugin supports these flows, so confirm the exact settings for your APISIX version in the plugin documentation before you commit to a design.

Can Keycloak fine-grained authorization be enforced at the APISIX gateway?

The gateway can enforce what the token carries, such as scopes, roles, groups or custom claims, through route-level checks. Keycloak fine-grained authorization services evaluate policies on Keycloak's side, so a decision made there must be expressed in a token or confirmed by a call the gateway makes. Whether a particular fine-grained decision can be checked at the gateway depends on how your policies are modeled and on which APISIX plugins you use. Treat this as a design question to confirm early: list the authorization rules you need, then test whether each can be enforced from token contents or must remain in the upstream service.

What ongoing work follows the go-live of a Keycloak and APISIX integration?

Ongoing work is recurring, and it should be budgeted separately from the project. Expect version upgrades for Keycloak and APISIX, which Keycloak documents as frequent minor releases with opt-in breaking changes, and which APISIX documents for its own releases. Client secret rotation needs a runbook covering the gateway configuration, the Keycloak client and any dependent services. For the Keycloak Operator, the project strongly recommends manual approval for operator updates, so decide who reviews and approves each update. Ask any partner for the support and upgrade scope in writing, and confirm what is covered by a retainer versus a one-time engagement.

How DeployOpen works on this

DeployOpen scopes Keycloak and Apache APISIX API authentication in writing before any work starts, then builds and tests the gateway and identity configuration inside your own infrastructure. Engagements are fixed-scope, and ongoing support is available as a retainer once the integration is live.

How we scope

  • Agree in writing which APIs, routes and consumers the gateway will protect and how each one is reached
  • Confirm which Keycloak realm, clients and token types each route will accept, including the flows each client needs
  • Record hostnames, TLS termination points and the APISIX deployment mode you run, traditional, decoupled or standalone
  • Set out which authorization decisions stay in the gateway and which stay in Keycloak, with the boundary written down

How we build

  • Configure the APISIX openid-connect plugin against your Keycloak client settings for authorization code, client credentials or introspection flows
  • Test token validation, expiry, refresh and rejected requests on a non-production route before any traffic moves
  • Keep Keycloak and APISIX configuration in version-controlled files so changes can be reviewed and repeated
  • Confirm that the Admin API and Keycloak administration endpoints are not exposed on public frontend hostnames

How we hand over

  • Deliver a runbook covering route-to-client mappings, token lifetimes, key rotation steps and the rollback procedure
  • Document test cases and their results so your team can repeat them after each change
  • Walk your operators through the APISIX and Keycloak dashboards, logs and metrics used to diagnose authentication failures
  • Provide a list of open items, such as client secret ownership and approval steps, that remain with your organization

How we support

  • Offer ongoing support, upgrades and continuous testing for the gateway and identity layer as a retainer
  • Plan Keycloak and APISIX upgrades against their published release notes and test them before production rollout
  • Review changes to plugins, routes and clients when your application teams add or retire APIs
  • Keep the support scope written down so it matches the systems and environments you ask us to cover

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.