Class OAuthBearerValidatorCallbackHandler
- java.lang.Object
-
- org.apache.kafka.common.security.oauthbearer.OAuthBearerValidatorCallbackHandler
-
- All Implemented Interfaces:
CallbackHandler,AuthenticateCallbackHandler
- Direct Known Subclasses:
OAuthBearerValidatorCallbackHandler
public class OAuthBearerValidatorCallbackHandler extends Object implements AuthenticateCallbackHandler
OAuthBearerValidatorCallbackHandleris anAuthenticateCallbackHandlerthat acceptsOAuthBearerValidatorCallbackandOAuthBearerExtensionsValidatorCallbackcallbacks to implement OAuth/OIDC validation. This callback handler is intended only to be used on the Kafka broker side as it will receive aOAuthBearerValidatorCallbackthat includes the JWT provided by the Kafka client. That JWT is validated in terms of format, expiration, signature, and audience and issuer (if desired). This callback handler is the broker side of the OAuth functionality, whereasOAuthBearerLoginCallbackHandleris used by clients.This
AuthenticateCallbackHandleris enabled in the broker configuration by setting theBrokerSecurityConfigs.SASL_SERVER_CALLBACK_HANDLER_CLASSlike so:listener.name..oauthbearer.sasl.server.callback.handler.class=org.apache.kafka.common.security.oauthbearer.OAuthBearerValidatorCallbackHandler The JAAS configuration for OAuth is also needed. If using OAuth for inter-broker communication, the options are those specified in
OAuthBearerLoginCallbackHandler.The configuration option
SaslConfigs.SASL_OAUTHBEARER_JWKS_ENDPOINT_URLis also required in order to contact the OAuth/OIDC provider to retrieve the JWKS for use in JWT signature validation. For example:listener.name.Please see the OAuth/OIDC providers documentation for the JWKS endpoint URL..oauthbearer.sasl.oauthbearer.jwks.endpoint.url=https://example.com/oauth2/v1/keys The following is a list of all the configuration options that are available for the broker validation callback handler:
BrokerSecurityConfigs.SASL_SERVER_CALLBACK_HANDLER_CLASSSaslConfigs.SASL_JAAS_CONFIGSaslConfigs.SASL_OAUTHBEARER_CLOCK_SKEW_SECONDSSaslConfigs.SASL_OAUTHBEARER_EXPECTED_AUDIENCESaslConfigs.SASL_OAUTHBEARER_EXPECTED_ISSUERSaslConfigs.SASL_OAUTHBEARER_JWKS_ENDPOINT_REFRESH_MSSaslConfigs.SASL_OAUTHBEARER_JWKS_ENDPOINT_RETRY_BACKOFF_MAX_MSSaslConfigs.SASL_OAUTHBEARER_JWKS_ENDPOINT_RETRY_BACKOFF_MSSaslConfigs.SASL_OAUTHBEARER_JWKS_ENDPOINT_URLSaslConfigs.SASL_OAUTHBEARER_SCOPE_CLAIM_NAMESaslConfigs.SASL_OAUTHBEARER_SUB_CLAIM_NAME
-
-
Constructor Summary
Constructors Constructor Description OAuthBearerValidatorCallbackHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes this instance.voidconfigure(Map<String,?> configs, String saslMechanism, List<AppConfigurationEntry> jaasConfigEntries)Configures this callback handler for the specified SASL mechanism.voidhandle(Callback[] callbacks)voidinit(org.apache.kafka.common.security.oauthbearer.internals.secured.CloseableVerificationKeyResolver verificationKeyResolver, org.apache.kafka.common.security.oauthbearer.internals.secured.AccessTokenValidator accessTokenValidator)
-
-
-
Method Detail
-
configure
public void configure(Map<String,?> configs, String saslMechanism, List<AppConfigurationEntry> jaasConfigEntries)
Description copied from interface:AuthenticateCallbackHandlerConfigures this callback handler for the specified SASL mechanism.- Specified by:
configurein interfaceAuthenticateCallbackHandler- Parameters:
configs- Key-value pairs containing the parsed configuration options of the client or broker. Note that these are the Kafka configuration options and not the JAAS configuration options. JAAS config options may be obtained from `jaasConfigEntries` for callbacks which obtain some configs from the JAAS configuration. For configs that may be specified as both Kafka config as well as JAAS config (e.g. sasl.kerberos.service.name), the configuration is treated as invalid if conflicting values are provided.saslMechanism- Negotiated SASL mechanism. For clients, this is the SASL mechanism configured for the client. For brokers, this is the mechanism negotiated with the client and is one of the mechanisms enabled on the broker.jaasConfigEntries- JAAS configuration entries from the JAAS login context. This list contains a single entry for clients and may contain more than one entry for brokers if multiple mechanisms are enabled on a listener using static JAAS configuration where there is no mapping between mechanisms and login module entries. In this case, callback handlers can use the login module in `jaasConfigEntries` to identify the entry corresponding to `saslMechanism`. Alternatively, dynamic JAAS configuration optionSaslConfigs.SASL_JAAS_CONFIGmay be configured on brokers with listener and mechanism prefix, in which case only the configuration entry corresponding to `saslMechanism` will be provided in `jaasConfigEntries`.
-
init
public void init(org.apache.kafka.common.security.oauthbearer.internals.secured.CloseableVerificationKeyResolver verificationKeyResolver, org.apache.kafka.common.security.oauthbearer.internals.secured.AccessTokenValidator accessTokenValidator)
-
close
public void close()
Description copied from interface:AuthenticateCallbackHandlerCloses this instance.- Specified by:
closein interfaceAuthenticateCallbackHandler
-
handle
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
- Specified by:
handlein interfaceCallbackHandler- Throws:
IOExceptionUnsupportedCallbackException
-
-