Skip to content

Commit b58e523

Browse files
committed
refactor: remove client_auth Kafka listener
1 parent d6970d9 commit b58e523

2 files changed

Lines changed: 21 additions & 68 deletions

File tree

rust/operator-binary/src/crd/listener.rs

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ pub enum KafkaListenerProtocol {
3838
pub enum KafkaListenerName {
3939
#[strum(serialize = "CLIENT")]
4040
Client,
41-
#[strum(serialize = "CLIENT_AUTH")]
42-
ClientAuth,
4341
#[strum(serialize = "INTERNAL")]
4442
Internal,
4543
#[strum(serialize = "BOOTSTRAP")]
@@ -179,28 +177,7 @@ pub fn get_kafka_listener_config(
179177
BTreeMap::new();
180178

181179
// CLIENT
182-
if kafka_security.tls_client_authentication_class().is_some() {
183-
// 1) If client authentication required, we expose only CLIENT_AUTH connection with SSL
184-
listeners.push(KafkaListener {
185-
name: KafkaListenerName::ClientAuth,
186-
host: LISTENER_LOCAL_ADDRESS.to_string(),
187-
port: kafka_security.client_port().to_string(),
188-
});
189-
advertised_listeners.push(KafkaListener {
190-
name: KafkaListenerName::ClientAuth,
191-
host: node_address_cmd(STACKABLE_LISTENER_BROKER_DIR),
192-
port: node_port_cmd(
193-
STACKABLE_LISTENER_BROKER_DIR,
194-
kafka_security.client_port_name(),
195-
),
196-
});
197-
listener_security_protocol_map
198-
.insert(KafkaListenerName::ClientAuth, KafkaListenerProtocol::Ssl);
199-
listener_security_protocol_map.insert(
200-
KafkaListenerName::ControllerAuth,
201-
KafkaListenerProtocol::Ssl,
202-
);
203-
} else if kafka_security.has_kerberos_enabled() {
180+
if kafka_security.has_kerberos_enabled() {
204181
// 2) Kerberos and TLS authentication classes are mutually exclusive
205182
listeners.push(KafkaListener {
206183
name: KafkaListenerName::Client,
@@ -217,12 +194,10 @@ pub fn get_kafka_listener_config(
217194
});
218195
listener_security_protocol_map
219196
.insert(KafkaListenerName::Client, KafkaListenerProtocol::SaslSsl);
220-
listener_security_protocol_map.insert(
221-
KafkaListenerName::Controller,
222-
KafkaListenerProtocol::SaslSsl,
223-
);
224-
} else if kafka_security.tls_server_secret_class().is_some() {
225-
// 3) If no client authentication but tls is required we expose CLIENT with SSL
197+
} else if kafka_security.tls_client_authentication_class().is_some()
198+
|| kafka_security.tls_server_secret_class().is_some()
199+
{
200+
// 1) Client listener uses TLS (possibly with authentication)
226201
listeners.push(KafkaListener {
227202
name: KafkaListenerName::Client,
228203
host: LISTENER_LOCAL_ADDRESS.to_string(),
@@ -239,7 +214,8 @@ pub fn get_kafka_listener_config(
239214
listener_security_protocol_map
240215
.insert(KafkaListenerName::Client, KafkaListenerProtocol::Ssl);
241216
} else {
242-
// 4) If no client auth or tls is required we expose CLIENT with PLAINTEXT
217+
// 3) If no client auth or tls is required we expose CLIENT with PLAINTEXT
218+
// This is actually never the case because
243219
listeners.push(KafkaListener {
244220
name: KafkaListenerName::Client,
245221
host: LISTENER_LOCAL_ADDRESS.to_string(),
@@ -414,7 +390,7 @@ mod tests {
414390
config.listeners(),
415391
format!(
416392
"{name}://{host}:{port},{internal_name}://{internal_host}:{internal_port}",
417-
name = KafkaListenerName::ClientAuth,
393+
name = KafkaListenerName::Client,
418394
host = LISTENER_LOCAL_ADDRESS,
419395
port = kafka_security.client_port(),
420396
internal_name = KafkaListenerName::Internal,
@@ -427,7 +403,7 @@ mod tests {
427403
config.advertised_listeners(),
428404
format!(
429405
"{name}://{host}:{port},{internal_name}://{internal_host}:{internal_port}",
430-
name = KafkaListenerName::ClientAuth,
406+
name = KafkaListenerName::Client,
431407
host = node_address_cmd(STACKABLE_LISTENER_BROKER_DIR),
432408
port = node_port_cmd(
433409
STACKABLE_LISTENER_BROKER_DIR,
@@ -447,15 +423,13 @@ mod tests {
447423
assert_eq!(
448424
config.listener_security_protocol_map(),
449425
format!(
450-
"{name}:{protocol},{internal_name}:{internal_protocol},{controller_name}:{controller_protocol},{controller_auth_name}:{controller_auth_protocol}",
451-
name = KafkaListenerName::ClientAuth,
426+
"{name}:{protocol},{internal_name}:{internal_protocol},{controller_name}:{controller_protocol}",
427+
name = KafkaListenerName::Client,
452428
protocol = KafkaListenerProtocol::Ssl,
453429
internal_name = KafkaListenerName::Internal,
454430
internal_protocol = KafkaListenerProtocol::Ssl,
455431
controller_name = KafkaListenerName::Controller,
456432
controller_protocol = KafkaListenerProtocol::Ssl,
457-
controller_auth_name = KafkaListenerName::ControllerAuth,
458-
controller_auth_protocol = KafkaListenerProtocol::Ssl,
459433
)
460434
);
461435

rust/operator-binary/src/crd/security.rs

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -531,37 +531,9 @@ impl KafkaTlsSecurity {
531531
// We set either client tls with authentication or client tls without authentication
532532
// If authentication is explicitly required we do not want to have any other CAs to
533533
// be trusted.
534-
if self.tls_client_authentication_class().is_some() {
535-
config.insert(
536-
KafkaListenerName::ClientAuth.listener_ssl_keystore_location(),
537-
format!("{}/keystore.p12", Self::STACKABLE_TLS_KAFKA_SERVER_DIR),
538-
);
539-
config.insert(
540-
KafkaListenerName::ClientAuth.listener_ssl_keystore_password(),
541-
Self::SSL_STORE_PASSWORD.to_string(),
542-
);
543-
config.insert(
544-
KafkaListenerName::ClientAuth.listener_ssl_keystore_type(),
545-
"PKCS12".to_string(),
546-
);
547-
config.insert(
548-
KafkaListenerName::ClientAuth.listener_ssl_truststore_location(),
549-
format!("{}/truststore.p12", Self::STACKABLE_TLS_KAFKA_SERVER_DIR),
550-
);
551-
config.insert(
552-
KafkaListenerName::ClientAuth.listener_ssl_truststore_password(),
553-
Self::SSL_STORE_PASSWORD.to_string(),
554-
);
555-
config.insert(
556-
KafkaListenerName::ClientAuth.listener_ssl_truststore_type(),
557-
"PKCS12".to_string(),
558-
);
559-
// client auth required
560-
config.insert(
561-
KafkaListenerName::ClientAuth.listener_ssl_client_auth(),
562-
"required".to_string(),
563-
);
564-
} else if self.tls_server_secret_class().is_some() {
534+
if self.tls_client_authentication_class().is_some()
535+
|| self.tls_server_secret_class().is_some()
536+
{
565537
config.insert(
566538
KafkaListenerName::Client.listener_ssl_keystore_location(),
567539
format!("{}/keystore.p12", Self::STACKABLE_TLS_KAFKA_SERVER_DIR),
@@ -586,6 +558,13 @@ impl KafkaTlsSecurity {
586558
KafkaListenerName::Client.listener_ssl_truststore_type(),
587559
"PKCS12".to_string(),
588560
);
561+
if self.tls_client_authentication_class().is_some() {
562+
// client auth required
563+
config.insert(
564+
KafkaListenerName::Client.listener_ssl_client_auth(),
565+
"required".to_string(),
566+
);
567+
}
589568
}
590569

591570
if self.has_kerberos_enabled() {

0 commit comments

Comments
 (0)