'Kafka admin sass config not recognized
I'm trying to configure spring Kafka admin with sass but I receive this error:
2021-12-14 19:59:56.238 WARN 37398 --- [ Test worker] o.a.k.clients.admin.AdminClientConfig : The configuration 'sasl.login.callback.handler.class' was supplied but isn't a known config.
2021-12-14 19:59:56.238 WARN 37398 --- [ Test worker] o.a.k.clients.admin.AdminClientConfig : The configuration 'sasl.jaas.config' was supplied but isn't a known config.
I'm quite sure that the sasl.login.callback.handler.class and sasl.jaas.config are right but I don't know how it gives me this error.
The configuration is:
@Bean
public KafkaAdmin kafkaAdmin() throws IOException {
Map<String, Object> props = new HashMap<>();
Resource saslConfigFile = resourceLoader.getResource("classpath:sasl-config.conf");
String config = StreamUtils.copyToString(saslConfigFile.getInputStream(), defaultCharset());
props.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, queue_server_address);
props.put(AdminClientConfig.CLIENT_ID_CONFIG, String.format("%s-admin", queue_client_id));
if (enableAuthentication) {
props.put("sasl.login.callback.handler.class", "it.infn.kafka.security.oauthbearer.OauthAuthenticateLoginCallbackHandler");
props.put(SaslConfigs.SASL_JAAS_CONFIG, config
.replace("${kafka_oauth_server}", filterOIDCHTTPrefix(oidcProperties.authServer))
.replace("${kafka_oauth_client_id}", oidcProperties.clientId)
.replace("${kafka_oauth_secret}", oidcProperties.clientSecret));
props.put("sasl.mechanism", "OAUTHBEARER");
props.put("security.protocol", "SASL_PLAINTEXT");
}
return new KafkaAdmin(props);
}
the salsa config file has this content:
org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required
OAUTH_LOGIN_SERVER="${kafka_oauth_server}"
OAUTH_LOGIN_ENDPOINT="/realms/test-realm/protocol/openid-connect/token"
OAUTH_LOGIN_GRANT_TYPE="client_credentials"
OAUTH_LOGIN_SCOPE="profile"
OAUTH_CLIENT_ID="${kafka_oauth_client_id}"
OAUTH_CLIENT_SECRET="${kafka_oauth_secret}"
OAUTH_INTROSPECT_SERVER="${kafka_oauth_server}"
OAUTH_INTROSPECT_ENDPOINT="/realms/test-realm/protocol/openid-connect/token/introspect"
OAUTH_REFRESH_GRANT_TYPE="refresh_token"
OAUTH_ACCEPT_UNSECURE_SERVER=true
OAUTH_WITH_SSL=false;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
