Chapter 88. KafkaClientAuthenticationOAuth schema reference Used in: KafkaBridgeSpec , KafkaConnectSpec , KafkaMirrorMaker2ClusterSpec , KafkaMirrorMakerConsumerSpec , KafkaMirrorMakerProducerSpec Full list of KafkaClientAuthenticationOAuth schema properties To configure OAuth client authentication, set the type property to oauth . OAuth authentication can be configured using one of the following options: Client ID and secret Client ID and refresh token Access token Username and password TLS Client ID and secret You can configure the address of your authorization server in the tokenEndpointUri property together with the client ID and client secret used in authentication. The OAuth client will connect to the OAuth server, authenticate using the client ID and secret and get an access token which it will use to authenticate with the Kafka broker. In the clientSecret property, specify a link to a Secret containing the client secret. Example client ID and client secret configuration authentication: type: oauth tokenEndpointUri: https://<auth_server_address>/<path_to_token_endpoint> clientId: my-client-id clientSecret: secretName: my-client-oauth-secret key: client-secret Optionally, scope and audience can be specified if needed. Client ID and refresh token You can configure the address of your OAuth server in the tokenEndpointUri property together with the OAuth client ID and refresh token. The OAuth client will connect to the OAuth server, authenticate using the client ID and refresh token and get an access token which it will use to authenticate with the Kafka broker. In the refreshToken property, specify a link to a Secret containing the refresh token. Example client ID and refresh token configuration authentication: type: oauth tokenEndpointUri: https://<auth_server_address>/<path_to_token_endpoint> clientId: my-client-id refreshToken: secretName: my-refresh-token-secret key: refresh-token Access token You can configure the access token used for authentication with the Kafka broker directly. In this case, you do not specify the tokenEndpointUri . In the accessToken property, specify a link to a Secret containing the access token. Alternatively, use accessTokenLocation property, and specify a path to the token file. Example access token only configuration authentication: type: oauth accessToken: secretName: my-access-token-secret key: access-token Example (service account) access token configuration specifying a mounted file authentication: type: oauth accessTokenLocation: `/var/run/secrets/kubernetes.io/serviceaccount/token` Username and password OAuth username and password configuration uses the OAuth Resource Owner Password Grant mechanism. The mechanism is deprecated, and is only supported to enable integration in environments where client credentials (ID and secret) cannot be used. You might need to use user accounts if your access management system does not support another approach or user accounts are required for authentication. A typical approach is to create a special user account in your authorization server that represents your client application. You then give the account a long randomly generated password and a very limited set of permissions. For example, the account can only connect to your Kafka cluster, but is not allowed to use any other services or login to the user interface. Consider using a refresh token mechanism first. You can configure the address of your authorization server in the tokenEndpointUri property together with the client ID, username and the password used in authentication. The OAuth client will connect to the OAuth server, authenticate using the username, the password, the client ID, and optionally even the client secret to obtain an access token which it will use to authenticate with the Kafka broker. In the passwordSecret property, specify a link to a Secret containing the password. Normally, you also have to configure a clientId using a public OAuth client. If you are using a confidential OAuth client, you also have to configure a clientSecret . Example username and password configuration with a public client authentication: type: oauth tokenEndpointUri: https://<auth_server_address>/<path_to_token_endpoint> username: my-username passwordSecret: secretName: my-password-secret-name password: my-password-field-name clientId: my-public-client-id Example username and password configuration with a confidential client authentication: type: oauth tokenEndpointUri: https://<auth_server_address>/<path_to_token_endpoint> username: my-username passwordSecret: secretName: my-password-secret-name password: my-password-field-name clientId: my-confidential-client-id clientSecret: secretName: my-confidential-client-oauth-secret key: client-secret Optionally, scope and audience can be specified if needed. TLS Accessing the OAuth server using the HTTPS protocol does not require any additional configuration as long as the TLS certificates used by it are signed by a trusted certification authority and its hostname is listed in the certificate. If your OAuth server uses self-signed certificates or certificates signed by an untrusted certification authority, use the tlsTrustedCertificates property to specify the secrets containing them. The certificates must be in X.509 format. Example configuration specifying TLS certificates authentication: type: oauth tokenEndpointUri: https://<auth_server_address>/<path_to_token_endpoint> clientId: my-client-id refreshToken: secretName: my-refresh-token-secret key: refresh-token tlsTrustedCertificates: - secretName: oauth-server-ca pattern: "*.crt" The OAuth client will by default verify that the hostname of your OAuth server matches either the certificate subject or one of the alternative DNS names. If it is not required, you can disable the hostname verification. Example configuration to disable TLS hostname verification authentication: type: oauth tokenEndpointUri: https://<auth_server_address>/<path_to_token_endpoint> clientId: my-client-id refreshToken: secretName: my-refresh-token-secret key: refresh-token disableTlsHostnameVerification: true 88.1. KafkaClientAuthenticationOAuth schema properties The type property is a discriminator that distinguishes use of the KafkaClientAuthenticationOAuth type from KafkaClientAuthenticationTls , KafkaClientAuthenticationScramSha256 , KafkaClientAuthenticationScramSha512 , KafkaClientAuthenticationPlain . It must have the value oauth for the type KafkaClientAuthenticationOAuth . Property Property type Description type string Must be oauth . clientId string OAuth Client ID which the Kafka client can use to authenticate against the OAuth server and use the token endpoint URI. username string Username used for the authentication. scope string OAuth scope to use when authenticating against the authorization server. Some authorization servers require this to be set. The possible values depend on how authorization server is configured. By default scope is not specified when doing the token endpoint request. audience string OAuth audience to use when authenticating against the authorization server. Some authorization servers require the audience to be explicitly set. The possible values depend on how the authorization server is configured. By default, audience is not specified when performing the token endpoint request. tokenEndpointUri string Authorization server token endpoint URI. connectTimeoutSeconds integer The connect timeout in seconds when connecting to authorization server. If not set, the effective connect timeout is 60 seconds. readTimeoutSeconds integer The read timeout in seconds when connecting to authorization server. If not set, the effective read timeout is 60 seconds. httpRetries integer The maximum number of retries to attempt if an initial HTTP request fails. If not set, the default is to not attempt any retries. httpRetryPauseMs integer The pause to take before retrying a failed HTTP request. If not set, the default is to not pause at all but to immediately repeat a request. clientSecret GenericSecretSource Link to OpenShift Secret containing the OAuth client secret which the Kafka client can use to authenticate against the OAuth server and use the token endpoint URI. passwordSecret PasswordSecretSource Reference to the Secret which holds the password. accessToken GenericSecretSource Link to OpenShift Secret containing the access token which was obtained from the authorization server. refreshToken GenericSecretSource Link to OpenShift Secret containing the refresh token which can be used to obtain access token from the authorization server. tlsTrustedCertificates CertSecretSource array Trusted certificates for TLS connection to the OAuth server. disableTlsHostnameVerification boolean Enable or disable TLS hostname verification. Default value is false . maxTokenExpirySeconds integer Set or limit time-to-live of the access tokens to the specified number of seconds. This should be set if the authorization server returns opaque tokens. accessTokenIsJwt boolean Configure whether access token should be treated as JWT. This should be set to false if the authorization server returns opaque tokens. Defaults to true . enableMetrics boolean Enable or disable OAuth metrics. Default value is false . includeAcceptHeader boolean Whether the Accept header should be set in requests to the authorization servers. The default value is true . accessTokenLocation string Path to the token file containing an access token to be used for authentication. clientAssertion GenericSecretSource Link to OpenShift secret containing the client assertion which was manually configured for the client. clientAssertionLocation string Path to the file containing the client assertion to be used for authentication. clientAssertionType string The client assertion type. If not set, and either clientAssertion or clientAssertionLocation is configured, this value defaults to urn:ietf:params:oauth:client-assertion-type:jwt-bearer . saslExtensions map SASL extensions parameters.

Commands:
authentication: type: oauth tokenEndpointUri: https://<auth_server_address>/<path_to_token_endpoint> clientId: my-client-id clientSecret: secretName: my-client-oauth-secret key: client-secret
authentication: type: oauth tokenEndpointUri: https://<auth_server_address>/<path_to_token_endpoint> clientId: my-client-id refreshToken: secretName: my-refresh-token-secret key: refresh-token
authentication: type: oauth accessToken: secretName: my-access-token-secret key: access-token
authentication: type: oauth accessTokenLocation: `/var/run/secrets/kubernetes.io/serviceaccount/token`
authentication: type: oauth tokenEndpointUri: https://<auth_server_address>/<path_to_token_endpoint> username: my-username passwordSecret: secretName: my-password-secret-name password: my-password-field-name clientId: my-public-client-id
authentication: type: oauth tokenEndpointUri: https://<auth_server_address>/<path_to_token_endpoint> username: my-username passwordSecret: secretName: my-password-secret-name password: my-password-field-name clientId: my-confidential-client-id clientSecret: secretName: my-confidential-client-oauth-secret key: client-secret
authentication: type: oauth tokenEndpointUri: https://<auth_server_address>/<path_to_token_endpoint> clientId: my-client-id refreshToken: secretName: my-refresh-token-secret key: refresh-token tlsTrustedCertificates: - secretName: oauth-server-ca pattern: "*.crt"
authentication: type: oauth tokenEndpointUri: https://<auth_server_address>/<path_to_token_endpoint> clientId: my-client-id refreshToken: secretName: my-refresh-token-secret key: refresh-token disableTlsHostnameVerification: true