@@ -42,6 +42,13 @@ const OPA_TLS_MOUNT_PATH: &str = "/stackable/tls-opa";
4242const OPA_TLS_VOLUME_NAME : & str = "tls-opa" ;
4343const SSL_STORE_PASSWORD : & str = "" ;
4444const SSL_STORE_TYPE_PKCS12 : & str = "PKCS12" ;
45+ const SSL_CLIENT_AUTH_REQUIRED : & str = "required" ;
46+ const SASL_MECHANISM_GSSAPI : & str = "GSSAPI" ;
47+ const STACKABLE_KCAT_BINARY : & str = "/stackable/kcat" ;
48+ const PROPERTY_SECURITY_PROTOCOL : & str = "security.protocol" ;
49+ const PROPERTY_SASL_ENABLED_MECHANISMS : & str = "sasl.enabled.mechanisms" ;
50+ const PROPERTY_SASL_KERBEROS_SERVICE_NAME : & str = "sasl.kerberos.service.name" ;
51+ const PROPERTY_SASL_INTER_BROKER_MECHANISM : & str = "sasl.mechanism.inter.broker.protocol" ;
4552const STACKABLE_TLS_KAFKA_INTERNAL_DIR : & str = "/stackable/tls-kafka-internal" ;
4653const STACKABLE_TLS_KAFKA_INTERNAL_VOLUME_NAME : & str = "tls-kafka-internal" ;
4754const STACKABLE_TLS_KAFKA_SERVER_DIR : & str = "/stackable/tls-kafka-server" ;
@@ -91,7 +98,7 @@ pub fn kcat_prober_container_commands(security: &ValidatedKafkaSecurity) -> Vec<
9198 let port = security. client_port ( ) ;
9299
93100 if security. tls_client_authentication_class ( ) . is_some ( ) {
94- args. push ( "/stackable/kcat" . to_string ( ) ) ;
101+ args. push ( STACKABLE_KCAT_BINARY . to_string ( ) ) ;
95102 args. push ( "-b" . to_string ( ) ) ;
96103 args. push ( format ! ( "localhost:{}" , port) ) ;
97104 args. extend ( kcat_client_auth_ssl ( STACKABLE_TLS_KCAT_DIR ) ) ;
@@ -130,21 +137,21 @@ pub fn kcat_prober_container_commands(security: &ValidatedKafkaSecurity) -> Vec<
130137 )
131138 . to_string ( ) ,
132139 ) ;
133- bash_args. push ( "/stackable/kcat" . to_string ( ) ) ;
140+ bash_args. push ( STACKABLE_KCAT_BINARY . to_string ( ) ) ;
134141 bash_args. push ( "-b" . to_string ( ) ) ;
135142 bash_args. push ( "$POD_BROKER_LISTENER_ADDRESS:$POD_BROKER_LISTENER_PORT" . to_string ( ) ) ;
136143 bash_args. extend ( kcat_client_sasl_ssl ( STACKABLE_TLS_KCAT_DIR , service_name) ) ;
137144 bash_args. push ( "-L" . to_string ( ) ) ;
138145
139146 args. push ( bash_args. join ( " " ) ) ;
140147 } else if security. tls_server_secret_class ( ) . is_some ( ) {
141- args. push ( "/stackable/kcat" . to_string ( ) ) ;
148+ args. push ( STACKABLE_KCAT_BINARY . to_string ( ) ) ;
142149 args. push ( "-b" . to_string ( ) ) ;
143150 args. push ( format ! ( "localhost:{}" , port) ) ;
144151 args. extend ( kcat_client_ssl ( STACKABLE_TLS_KCAT_DIR ) ) ;
145152 args. push ( "-L" . to_string ( ) ) ;
146153 } else {
147- args. push ( "/stackable/kcat" . to_string ( ) ) ;
154+ args. push ( STACKABLE_KCAT_BINARY . to_string ( ) ) ;
148155 args. push ( "-b" . to_string ( ) ) ;
149156 args. push ( format ! ( "localhost:{}" , port) ) ;
150157 args. push ( "-L" . to_string ( ) ) ;
@@ -160,10 +167,13 @@ pub fn client_properties(security: &ValidatedKafkaSecurity) -> Vec<(String, Opti
160167
161168 if security. tls_client_authentication_class ( ) . is_some ( ) {
162169 props. push ( (
163- "security.protocol" . to_string ( ) ,
170+ PROPERTY_SECURITY_PROTOCOL . to_string ( ) ,
164171 Some ( KafkaListenerProtocol :: Ssl . to_string ( ) ) ,
165172 ) ) ;
166- props. push ( ( "ssl.client.auth" . to_string ( ) , Some ( "required" . to_string ( ) ) ) ) ;
173+ props. push ( (
174+ "ssl.client.auth" . to_string ( ) ,
175+ Some ( SSL_CLIENT_AUTH_REQUIRED . to_string ( ) ) ,
176+ ) ) ;
167177 push_client_ssl_stores ( & mut props, STACKABLE_TLS_KAFKA_SERVER_DIR ) ;
168178 } else if security. has_kerberos_enabled ( ) {
169179 // TODO: to make this configuration file usable out of the box the operator needs to be
@@ -172,21 +182,21 @@ pub fn client_properties(security: &ValidatedKafkaSecurity) -> Vec<(String, Opti
172182 // This will simplify the code and the command lines lot.
173183 // It will also make the jaas files reusable by the Kafka shell scripts.
174184 props. push ( (
175- "security.protocol" . to_string ( ) ,
185+ PROPERTY_SECURITY_PROTOCOL . to_string ( ) ,
176186 Some ( KafkaListenerProtocol :: SaslSsl . to_string ( ) ) ,
177187 ) ) ;
178188 push_client_ssl_stores ( & mut props, STACKABLE_TLS_KAFKA_SERVER_DIR ) ;
179189 props. push ( (
180- "sasl.enabled.mechanisms" . to_string ( ) ,
181- Some ( "GSSAPI" . to_string ( ) ) ,
190+ PROPERTY_SASL_ENABLED_MECHANISMS . to_string ( ) ,
191+ Some ( SASL_MECHANISM_GSSAPI . to_string ( ) ) ,
182192 ) ) ;
183193 props. push ( (
184- "sasl.kerberos.service.name" . to_string ( ) ,
194+ PROPERTY_SASL_KERBEROS_SERVICE_NAME . to_string ( ) ,
185195 Some ( KafkaRole :: Broker . kerberos_service_name ( ) . to_string ( ) ) ,
186196 ) ) ;
187197 props. push ( (
188- "sasl.mechanism.inter.broker.protocol" . to_string ( ) ,
189- Some ( "GSSAPI" . to_string ( ) ) ,
198+ PROPERTY_SASL_INTER_BROKER_MECHANISM . to_string ( ) ,
199+ Some ( SASL_MECHANISM_GSSAPI . to_string ( ) ) ,
190200 ) ) ;
191201 props. push ( (
192202 "sasl.jaas.config" . to_string ( ) ,
@@ -197,13 +207,13 @@ pub fn client_properties(security: &ValidatedKafkaSecurity) -> Vec<(String, Opti
197207 realm="$KERBEROS_REALM" ) ) ) ) ;
198208 } else if security. tls_server_secret_class ( ) . is_some ( ) {
199209 props. push ( (
200- "security.protocol" . to_string ( ) ,
210+ PROPERTY_SECURITY_PROTOCOL . to_string ( ) ,
201211 Some ( KafkaListenerProtocol :: Ssl . to_string ( ) ) ,
202212 ) ) ;
203213 push_client_ssl_truststore ( & mut props, STACKABLE_TLS_KAFKA_SERVER_DIR ) ;
204214 } else {
205215 props. push ( (
206- "security.protocol" . to_string ( ) ,
216+ PROPERTY_SECURITY_PROTOCOL . to_string ( ) ,
207217 Some ( KafkaListenerProtocol :: Plaintext . to_string ( ) ) ,
208218 ) ) ;
209219 }
@@ -417,7 +427,7 @@ pub fn broker_config_settings(security: &ValidatedKafkaSecurity) -> BTreeMap<Str
417427 // client auth required
418428 config. insert (
419429 KafkaListenerName :: Client . listener_ssl_client_auth ( ) ,
420- "required" . to_string ( ) ,
430+ SSL_CLIENT_AUTH_REQUIRED . to_string ( ) ,
421431 ) ;
422432 }
423433 }
@@ -429,14 +439,17 @@ pub fn broker_config_settings(security: &ValidatedKafkaSecurity) -> BTreeMap<Str
429439 & KafkaListenerName :: Bootstrap ,
430440 STACKABLE_TLS_KAFKA_SERVER_DIR ,
431441 ) ;
432- config. insert ( "sasl.enabled.mechanisms" . to_string ( ) , "GSSAPI" . to_string ( ) ) ;
433442 config. insert (
434- "sasl.kerberos.service.name" . to_string ( ) ,
443+ PROPERTY_SASL_ENABLED_MECHANISMS . to_string ( ) ,
444+ SASL_MECHANISM_GSSAPI . to_string ( ) ,
445+ ) ;
446+ config. insert (
447+ PROPERTY_SASL_KERBEROS_SERVICE_NAME . to_string ( ) ,
435448 KafkaRole :: Broker . kerberos_service_name ( ) . to_string ( ) ,
436449 ) ;
437450 config. insert (
438- "sasl.mechanism.inter.broker.protocol" . to_string ( ) ,
439- "GSSAPI" . to_string ( ) ,
451+ PROPERTY_SASL_INTER_BROKER_MECHANISM . to_string ( ) ,
452+ SASL_MECHANISM_GSSAPI . to_string ( ) ,
440453 ) ;
441454 tracing:: debug!( "Kerberos configs added: [{:#?}]" , config) ;
442455 }
@@ -458,7 +471,7 @@ pub fn broker_config_settings(security: &ValidatedKafkaSecurity) -> BTreeMap<Str
458471 // client auth required
459472 config. insert (
460473 KafkaListenerName :: Internal . listener_ssl_client_auth ( ) ,
461- "required" . to_string ( ) ,
474+ SSL_CLIENT_AUTH_REQUIRED . to_string ( ) ,
462475 ) ;
463476 }
464477
@@ -518,21 +531,24 @@ pub fn controller_config_settings(security: &ValidatedKafkaSecurity) -> BTreeMap
518531 // client auth required
519532 config. insert (
520533 KafkaListenerName :: Controller . listener_ssl_client_auth ( ) ,
521- "required" . to_string ( ) ,
534+ SSL_CLIENT_AUTH_REQUIRED . to_string ( ) ,
522535 ) ;
523536 }
524537 }
525538
526539 // Kerberos
527540 if security. has_kerberos_enabled ( ) {
528- config. insert ( "sasl.enabled.mechanisms" . to_string ( ) , "GSSAPI" . to_string ( ) ) ;
529541 config. insert (
530- "sasl.kerberos.service.name" . to_string ( ) ,
542+ PROPERTY_SASL_ENABLED_MECHANISMS . to_string ( ) ,
543+ SASL_MECHANISM_GSSAPI . to_string ( ) ,
544+ ) ;
545+ config. insert (
546+ PROPERTY_SASL_KERBEROS_SERVICE_NAME . to_string ( ) ,
531547 KafkaRole :: Controller . kerberos_service_name ( ) . to_string ( ) ,
532548 ) ;
533549 config. insert (
534- "sasl.mechanism.inter.broker.protocol" . to_string ( ) ,
535- "GSSAPI" . to_string ( ) ,
550+ PROPERTY_SASL_INTER_BROKER_MECHANISM . to_string ( ) ,
551+ SASL_MECHANISM_GSSAPI . to_string ( ) ,
536552 ) ;
537553 tracing:: debug!( "Kerberos configs added: [{:#?}]" , config) ;
538554 }
@@ -631,7 +647,7 @@ fn kcat_client_sasl_ssl(cert_directory: &str, service_name: &str) -> Vec<String>
631647 "-X" . to_string( ) ,
632648 "sasl.kerberos.keytab=/stackable/kerberos/keytab" . to_string( ) ,
633649 "-X" . to_string( ) ,
634- "sasl.mechanism=GSSAPI" . to_string ( ) ,
650+ format! ( "sasl.mechanism={SASL_MECHANISM_GSSAPI}" ) ,
635651 "-X" . to_string( ) ,
636652 format!( "sasl.kerberos.service.name={service_name}" ) ,
637653 "-X" . to_string( ) ,
0 commit comments