tallence / push-notification-kafka-plugin

A driver for Dovecot's Push Notification Framework for publishing push notification events to a Kafka broker.
Other
6 stars 4 forks source link

Use tls with librdbkafka #4

Closed jrse closed 6 years ago

jrse commented 6 years ago

Librdkafka does have SSL support (https://github.com/edenhill/librdkafka/wiki/Using-SSL-with-librdkafka)

Out of security considerations, it is always a good idea to use tls for network communication if available.

The notification plugin should have a configuration option to use ssl with the push-notification-kafka-plugin.

  1. There are two possible solutions to push the configuration to the plugin. a. use 90-plugin.conf with: <prefix>.<settingname>=<value> b. use "separate" configuration file (referenced in 90-plugin.conf)

The librdkafka library already supports a configuration object. (see. rdkafka_conf.c for all possible options)

Solution a:

Solution b:

jrse commented 6 years ago

Passwords in dovecot config files: AuthDatabase SQL: stores the pwd as plain text in configuration file

Dovecot encryption: There are dovecot encryption functions: in pasword-scheme.h which are used in the auth module and doveadm pw plugin.

encrypt: doveadm pw -s CRYPT

decrypt: passsword-scheme.h (passwd_decode)

jrse commented 6 years ago

List of all librdkafka configuration options: https://docs.confluent.io/2.0.0/clients/librdkafka/CONFIGURATION_8md.html

jrse commented 6 years ago

all configuration values now have kafka.notification prefix.

configuration settings as described in (https://docs.confluent.io/2.0.0/clients/librdkafka/CONFIGURATION_8md.html) can be passed directory to librdkafka. To pass the setting directly the prefix kafka.notification.settings is mandatory.

The following is an example to configure tls in 90-plugin.conf:

kafka.notification.kafka_brokers=:9093 kafka.notification.debug=all kafka.notification.settings.security.protocol=ssl kafka.notification.settings.ssl.key.location=client_host.key kafka.notification.settings.ssl.key.password=PLAINTEXT pwd kafka.notification.settings.ssl.certificate.location=client_host.pem kafka.notification.settings.ssl.ca.location=ca-cert

(To generate a test ca and certificates you can follow the howto at : https://github.com/edenhill/librdkafka/wiki/Using-SSL-with-librdkafka)

jrse commented 6 years ago

Dovecot test configuration, to test notification plugin with imaptest and imap clients.

./dovecot/conf.d/20-imap.conf: mail_plugins = $mail_plugins notify push_notification_kafka push_notification imap_acl ./dovecot/conf.d/20-lmtp.conf: mail_plugins = $mail_plugins notify push_notification_kafka push_notification ./dovecot/conf.d/90-plugin.conf: kafka.notification.kafka_brokers=jrse-box.fritz.box:9093 ./dovecot/conf.d/90-plugin.conf: kafka.notification.debug=all ./dovecot/conf.d/90-plugin.conf: kafka.notification.settings.security.protocol=ssl ./dovecot/conf.d/90-plugin.conf: kafka.notification.settings.ssl.key.location=clientclient.key ./dovecot/conf.d/90-plugin.conf: kafka.notification.settings.ssl.key.password=adcdefgh ./dovecot/conf.d/90-plugin.conf: kafka.notification.settings.ssl.certificate.location=clientclient.pem ./dovecot/conf.d/90-plugin.conf: kafka.notification.settings.ssl.ca.location=ca-cert ./dovecot/conf.d/90-plugin.conf: push_notification_driver=kafka