Externalise secrets from Debezium connector config


Card image cap

debezium-server-architecture

Credit: Image Source

Why we need to externalise the database credentials from debezium connector config?
Externalizing database credentials from a Debezium connector configuration is a security best practice that helps protect sensitive information and minimize potential security risks. Here are the main reasons why this practice is important:

Security: Storing database credentials (such as usernames and passwords) directly in the connector configuration files can expose them to unauthorized access. If an attacker gains access to these credentials, they could potentially access your database, leading to data breaches or other security incidents.

Separation of Concerns: By externalizing credentials, you can manage them separately from the connector configuration. This allows you to grant different levels of access to different individuals or systems. Database administrators can manage the credentials, while other users can configure and use the connectors without having direct access to the sensitive credentials.

Ease of Management: When credentials are externalized, it's easier to rotate or update them without modifying the connector configuration. This is particularly important for security compliance and best practices that recommend regular credential rotation.

Version Control: If credentials are embedded in the configuration files, it becomes challenging to manage version control. Any change to the credentials would result in changes to the configuration files, making it harder to track and manage configuration changes over time.

Auditing: Externalized credentials can be more easily audited, allowing you to track who has access to the credentials and when they were accessed or modified.

To externalize database credentials from a Debezium connector configuration, you can use configuration management tools, environment variables, secure credential storage solutions, or any other mechanism that separates the sensitive information from the configuration files. This practice enhances the overall security posture of your data integration pipelines.

docker-compose.yaml file


version: "1"
services:
  connect:
    hostname: kafkaconnect
    image: "kafka-connect-ubuntu:1.0.0"
    ports:
      - '8083:8083'
    environment:
      CONNECT_BOOTSTRAP_SERVERS: ""
      CONNECT_REST_PORT: "8083"
      KAFKA_JMX_PORT: "9012"
      KAFKA_JMX_HOSTNAME: ""
      CONNECT_GROUP_ID: "quickstart"
      CONNECT_CONFIG_STORAGE_TOPIC: "config"
      CONNECT_OFFSET_STORAGE_TOPIC: "offsets10"
      CONNECT_STATUS_STORAGE_TOPIC: "status"
      CONNECT_CONFIG_STORAGE_REPLICATION_FACTOR: "3"
      CONNECT_OFFSET_STORAGE_REPLICATION_FACTOR: "3"
      CONNECT_STATUS_STORAGE_REPLICATION_FACTOR: "3"
      CONNECT_KEY_CONVERTER: "org.apache.kafka.connect.json.JsonConverter"
      CONNECT_VALUE_CONVERTER: "org.apache.kafka.connect.json.JsonConverter"
      CONNECT_INTERNAL_KEY_CONVERTER: "org.apache.kafka.connect.json.JsonConverter"
      CONNECT_INTERNAL_VALUE_CONVERTER: "org.apache.kafka.connect.json.JsonConverter"
      CONNECT_REST_ADVERTISED_HOST_NAME: ""
      CONNECT_CONFIG_PROVIDERS: "file"
      CONNECT_CONFIG_PROVIDERS_FILE_CLASS: "org.apache.kafka.common.config.provider.FileConfigProvider"
      CONNECT_PLUGIN_PATH: /usr/share/java,/usr/share/confluent-hub-components



you can access the value of a field like in the connector config

"database.user": "${file:/home/appuser/secrets/dbcreds.properties:database_user}",
"database.password": "${file:/home/appuser/secrets/dbcreds.properties:database_password}",


 There is need to add the credentials in a .properties file and put the file in docker container

$ sudo docker exec -it  bash
$ mkdir secrets
$ pwd ## copy the path

## then exit the container
$ sudo docker cp dbcreds.properties container_id:/home/appuser/secrets/


 example.properties file

beta_homeyantra_database_user=db_username
beta_homeyantra_database_password=db_passeord



References
https://debezium.io/blog/2019/12/13/externalized-secrets/

Comments