
Per-listener configuration with
GATEWAY_LISTENER_<NAME>_* variables is available from Gateway 3.20.0. On earlier versions, networking is configured with the global variables described in Legacy network configuration. To move an existing deployment over, see Migrate to listener configuration.Principal that represents the authenticated identity of the Kafka client.
Configuring listener security involves two key decisions:
- Security mode (
GATEWAY_SECURITY_MODE): defines where authentication and authorization take place — Gateway or Kafka. This applies globally to all listeners. - Security protocol (
GATEWAY_LISTENER_<NAME>_SECURITY_PROTOCOL): defines how clients communicate and authenticate with a given listener. Set this per listener.
DEFAULT. To expose Gateway through multiple endpoints with different security, see Set up multiple listeners.
Security mode
TheGATEWAY_SECURITY_MODE environment variable determines where authentication and authorization take place. Gateway supports two modes:
GATEWAY_MANAGED
Gateway handles authentication and authorization. Use this mode when:- You want Gateway to manage clients’ credentials using local service accounts, or external ones from your identity provider (for OIDC) or certificates (for mTLS)
- You need Gateway to enforce ACLs
- You want the Gateway to be an abstraction layer that manages its own identities and ACLs
PLAINTEXT, SSL, SASL_PLAINTEXT, SASL_SSL
ACL behavior: Set GATEWAY_ACL_ENABLED to control ACL enforcement on the passthrough virtual cluster — typically true for this mode.
Example configuration:
KAFKA_MANAGED
Kafka handles authentication and authorization. Gateway forwards client credentials to the backing Kafka cluster. Use this mode when:- Your backing Kafka cluster manages all credentials
- You want clients to use their existing Kafka credentials through Gateway
- You need Gateway to respect Kafka’s ACLs and permissions
SASL_PLAINTEXT, SASL_SSL only
KAFKA_MANAGED mode is incompatible with PLAINTEXT or SSL security protocols because these protocols don’t support credential forwarding to Kafka.GATEWAY_ACL_ENABLED has to be false. Setting it to true causes a startup error.
Example configuration:
Security protocols
Gateway supports the following security protocols for client connections: In the table below, “security protocol” refers to the per-listenerGATEWAY_LISTENER_<NAME>_SECURITY_PROTOCOL setting.
| Clients ⟶ GW transit in plaintext | Clients ⟶ GW transit is encrypted | |
|---|---|---|
| Anonymous access only | Security mode: GATEWAY_MANAGEDSecurity protocol: PLAINTEXTAuthentication mechanism: None | Security mode: GATEWAY_MANAGEDSecurity protocol: SSLAuthentication mechanism: None |
| Credentials managed by Gateway | Security mode: GATEWAY_MANAGEDSecurity protocol: SASL_PLAINTEXTAuthentication mechanism: PLAIN | Security mode: GATEWAY_MANAGEDSecurity protocol: SASL_SSLAuthentication mechanism: PLAIN |
| Gateway configured with OAuth | Security mode: GATEWAY_MANAGEDSecurity protocol: SASL_PLAINTEXTAuthentication mechanism: OAUTHBEARER | Security mode: GATEWAY_MANAGEDSecurity protocol: SASL_SSLAuthentication mechanism: OAUTHBEARER |
| Clients are identified by certificates (mTLS) | Not possible (mTLS requires encryption) | Security mode: GATEWAY_MANAGEDSecurity protocol: SSLAuthentication mechanism: MTLS |
| Credentials managed by Kafka | Security mode: KAFKA_MANAGEDSecurity protocol: SASL_PLAINTEXTAuthentication mechanism: PLAIN, SCRAM-SHA-256, SCRAM-SHA-512, OAUTHBEARER or AWS_MSK_IAM | Security mode: KAFKA_MANAGEDSecurity protocol: SASL_SSLAuthentication mechanism: PLAIN, SCRAM-SHA-256, SCRAM-SHA-512, OAUTHBEARER or AWS_MSK_IAM |
Configure security protocol
TheGATEWAY_LISTENER_<NAME>_SECURITY_PROTOCOL environment variable defines how clients communicate with a given Gateway listener. In the examples below, the listener is named DEFAULT.
The global
GATEWAY_SECURITY_PROTOCOL is deprecated in favor of the per-listener GATEWAY_LISTENER_<NAME>_SECURITY_PROTOCOL. If your deployment still sets it, see Legacy network configuration.PLAINTEXT
There is no client authentication to Gateway and all communication is exchanged without any network security. Security mode:GATEWAY_MANAGED only
Gateway configuration:
SSL
With SSL only, there is no client authentication, but communication between the client and Gateway broker will be encrypted. Security mode:GATEWAY_MANAGED only
Gateway configuration:
mTLS
Mutual TLS leverages client side certificates to authenticate a Kafka client.Principal for an mTLS connection can be detected from the subject of the certificate using the same feature as Apache Kafka, the SSL principal mapping.
Security mode: GATEWAY_MANAGED only
Gateway configuration:
SASL_PLAINTEXT
Authentication from the client is mandatory but all communications are exchanged without any network security. Security mode:GATEWAY_MANAGED or KAFKA_MANAGED
You don’t set
GATEWAY_SASL_MECHANISM — this environment variable does not exist. Gateway automatically detects the authentication mechanism based on how the client presents itself. For example, if a client uses OAUTHBEARER, Gateway uses the OAuth configuration. If a client uses PLAIN, Gateway validates credentials based on the security mode.Gateway-managed (PLAIN mechanism)
Plain mechanism uses username/password credentials to authenticate against Gateway. Credentials take the form of a JWT token managed in Gateway using the Admin (HTTP) API. Gateway configuration:GATEWAY_USER_POOL_SECRET_KEY has to be set to a random base64-encoded value of 256 bits to ensure that tokens aren’t forged. For example: openssl rand -base64 32. This value is required — Gateway has no default.
Client configuration:
- Create the service account, the username
- Generate a token for the service account, the password
Gateway-managed (OAUTHBEARER mechanism)
OAuthbearer uses an OAuth2/OIDC security provider to authenticate a token in Gateway. The OAuth credentials base is managed in the configured provider. This mechanism also allows you to verify claims from your OIDC provider (audience and issuer).
Gateway configuration:
Kafka-managed
Gateway forwards client credentials to the backing Kafka cluster for authentication. Credentials are managed by your backing Kafka cluster. Supported SASL mechanisms:PLAIN, SCRAM-SHA-256, SCRAM-SHA-512, OAUTHBEARER, AWS_MSK_IAM
Gateway configuration:
SASL_SSL
Authentication from client is mandatory and communication will be encrypted using TLS. Security mode:GATEWAY_MANAGED or KAFKA_MANAGED
You don’t set
GATEWAY_SASL_MECHANISM — this environment variable does not exist. Gateway automatically detects the authentication mechanism based on how the client presents itself. For example, if a client uses OAUTHBEARER, Gateway uses the OAuth configuration. If a client uses PLAIN, Gateway validates credentials based on the security mode.Gateway-managed (PLAIN mechanism)
Plain mechanism uses username/password credentials to authenticate against Gateway. Credentials are managed in Gateway using the HTTP API. Gateway configuration:GATEWAY_USER_POOL_SECRET_KEY to a random value to ensure that tokens cannot be forged. This value is required — Gateway has no default.
Client configuration:
Gateway-managed (OAUTHBEARER mechanism)
OAuthbearer uses an OAuth2/OIDC security provider to authenticate a token in Gateway. The OAuth credentials base is managed in the configured provider. This mechanism also allows you to verify claims from your OIDC provider (audience and issuer).
Gateway configuration:
Kafka-managed
Gateway forwards client credentials to the backing Kafka cluster for authentication. Credentials are managed by your backing Kafka cluster. Supported SASL mechanisms:PLAIN, SCRAM-SHA-256, SCRAM-SHA-512, OAUTHBEARER, AWS_MSK_IAM
Gateway configuration:
Principal resolver
When using Confluent Cloud authentication with Kafka-managed mode, Gateway supports automatically resolving API keys to their associated service account. This feature enhances security and improves usability by working with the service account principals instead of raw API keys. See the principal resolver environment variables. Gateway configuration using environment variables:The value of
GATEWAY_CONFLUENT_CLOUD_API_KEY has to be a Confluent Cloud API key because it will be used to access the Confluent Cloud API. Find out more about Confluent Cloud API keys.XIGMNERQXOUKXDQU) to their associated owner, which will be either the user (e.g. u-12345) or the service account (e.g. sa-72839j).