Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Securing access to REST API of Kafka Connect

The REST API for Kafka Connect is not secured and authenticated. Since its not authenticated, the configuration for a connector or Tasks are easily accessible by anyone. Since these configurations may contain about how to access the Source System [in case of SourceConnector] and destination system [in case of SinkConnector], Is there a standard way to restrict access to these APIs?

like image 354
Prabha Avatar asked Jul 22 '17 04:07

Prabha


People also ask

Can Kafka connect to REST API?

Since Kafka Connect is intended to be run as a service, it also supports a REST API for managing connectors. By default this service runs on port 8083 . When executed in distributed mode, the REST API will be the primary interface to the cluster.

What is the protocol used by Kafka clients to securely connect to the confluent rest proxy?

You can use HTTP Basic Authentication or mutual TLS (mTLS) authentication for communication between a client and REST Proxy. You can use SASL or mTLS for communication between REST Proxy and the brokers.

What is the difference between Kafka and Kafka connect?

Apache Kafka is a distributed streaming platform and kafka Connect is framework for connecting kafka with external systems like databases, key-value stores, search indexes, and file systems, using so-called Connectors.


3 Answers

In Kafka 2.1.0, there is possibility to configure http basic authentication for REST interface of Kafka Connect without writing any custom code.

This became real due to implementation of REST extensions mechanism (see KIP-285).

Shortly, configuration procedure as follows:

  1. Add extension class to worker configuration file:
rest.extension.classes = org.apache.kafka.connect.rest.basic.auth.extension.BasicAuthSecurityRestExtension
  1. Create JAAS config file (i.e. connect_jaas.conf) for application name 'KafkaConnect':
KafkaConnect {
   org.apache.kafka.connect.rest.basic.auth.extension.PropertyFileLoginModule required
             file="/your/path/rest-credentials.properties";
};
  1. Create rest-credentials.properties file in above-mentioned directory:
user=password
  1. Finally, inform java about you JAAS config file, for example, by adding command-line property to java:
-Djava.security.auth.login.config=/your/path/connect_jaas.conf 

After restarting Kafka Connect, you will be unable to use REST API without basic authentication.

Please keep in mind that used classes are rather examples than production-ready features.

Links:

  • Connect configuratin
  • BasicAuthSecurityRestExtension
  • JaasBasicAuthFilter
  • PropertyFileLoginModule
like image 108
Eugene Avatar answered Oct 14 '22 12:10

Eugene


Now you are able to enable certificate based authentication for client access to the REST API of Kafka Connect. An example here https://github.com/sudar-path/kc-rest-mtls

like image 28
sudar-path Avatar answered Oct 14 '22 12:10

sudar-path


As of Kafka 1.1.0, you can set up SSL and SSL client authentication for the Kafka Connect REST API. See KIP-208 for the details.

like image 33
Gunnar Avatar answered Oct 14 '22 13:10

Gunnar