UNPKG

node-red-contrib-rdkafka-secure

Version:

Node-RED module for secure Apache Kafka publish/subscribe using the librdkafka C library

241 lines (222 loc) 11.4 kB
<script type="text/x-red" data-template-name="rdkafka-secure in"> <div class="form-row"> <label for="node-input-broker"><i class="icon-tag"></i> Broker</label> <input type="text" id="node-input-broker"> </div> <div class="form-row"> <label for="node-input-topic"><i class="icon-tasks"></i> Topic</label> <input type="text" id="node-input-topic" placeholder="Topic"> </div> <div class="form-row"> <label for="node-input-cgroup"><i class="icon-tasks"></i> Group ID</label> <input type="text" id="node-input-cgroup" placeholder="Group ID"> </div> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> </script> <script type="text/x-red" data-help-name="rdkafka-secure in"> <p>Kafka input node. Connects to a broker and subscribes to the specified topic. The topic may contain Kafka wildcard regular expression. </script> <script type="text/javascript"> RED.nodes.registerType('rdkafka-secure in',{ category: 'network', defaults: { name: {value:""}, topic: {value:"",required:true}, cgroup: {value:"node-red-rdkafka-secure"}, autocommit: {value:true, required:true}, broker: {type:"kafka-broker-secure", required:true} }, color:"#FFFFFF", inputs:0, outputs:1, icon: "kafka.png", label: function() { return this.name||this.topic||"rdkafka-secure"; }, labelStyle: function() { return this.name?"node_label_italic":""; }, paletteLabel: "Kafka in" }); </script> <script type="text/x-red" data-template-name="rdkafka-secure out"> <div class="form-row"> <label for="node-input-broker"><i class="icon-tag"></i> Broker</label> <input type="text" id="node-input-broker"> </div> <div class="form-row"> <label for="node-input-topic"><i class="icon-tasks"></i> Topic</label> <input type="text" id="node-input-topic" placeholder="Topic"> </div> <div class="form-row"> <label for="node-input-key"><i class="icon-tasks"></i> Key</label> <input type="text" id="node-input-key" placeholder="Key"> </div> <div class="form-row"> <label for="node-input-partition"><i class="icon-tasks"></i> Partition</label> <input type="number" id="node-input-partition" placeholder="Partition"> </div> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> </script> <script type="text/x-red" data-help-name="rdkafka-secure out"> <p>Connects to a Kafka broker and publishes messages. <p>If you want to publish Kafka messages in Key,Value format then either specify a static key value in the config dialog or (if blank) include a key string in the incoming <code>msg.key</code> field <p>The Kafka topic to which messages are published can be specified as a static topic value in the config dialog or (if blank) included as a topic string in the incoming <code>msg.topic</code> field <p>The Kafka partition to which messages are published can be specified as a static partition value in the config dialog or (if set to -1) included as a topic string in the incoming <code>msg.partition</code> field. If no partition is specified via either method then the default (round robin) Kafka partitioner is used. <p>If you provide a valid timestamp by using the <code>msg.timestamp</code> field it will be added to the message as the event time, otherwise the current publish time will be used. <p>If any values are set in both the configuration window and in the incoming message, then the configuration dialog value has precedence. <p>The output of this node includes key_schema_id, value and <code>offsets</code> which is an array of objects containing the partition, offset, error_code, and error for each of the messages published. For example <code>{ offsets: [ { partition: 0, offset: 1071, error_code: null, error: null } ], key_schema_id: null, value_schema_id: null }</code> </script> <script type="text/javascript"> RED.nodes.registerType('rdkafka-secure out',{ category: 'network', defaults: { name: {value:""}, topic: {value:"", required: true}, key: {value:""}, partition: {value:-1}, broker: {type:"kafka-broker-secure", required:true} }, color:"#FFFFFF", inputs:1, outputs:0, icon: "kafka.png", align: "right", label: function() { return this.name||this.topic||"rdkafka-secure"; }, labelStyle: function() { return this.name?"node_label_italic":""; }, paletteLabel: "Kafka out" }); </script> <script type="text/x-red" data-help-name="kafka-broker-secure"> <dl class="message-properties"> <dt>Broker List <span class="property-type">string</span> </dt> <dd> Comma-separated list of Kafka brokers, in the form HOST1:PORT1[,HOST2:PORT2[...]] </dd> <dt class="optional">Client ID <span class="property-type">string</span></dt> <dd> Client identifier. Leave blank for an auto-generated client ID.</dd> <dt>Security protocol <span class="property-type">string</span> </dt> <dd> Protocol used to communicate with brokers. </dd> <dt>SASL mechanism <span class="property-type">string</span> </dt> <dd> SASL mechanism to use for authentication. </dd> <dt class="optional">SASL username <span class="property-type">string</span> </dt> <dd> SASL username for use with the PLAIN, and SCRAM-SHA mechanisms. </dd> <dt class="optional">SASL password <span class="property-type">string</span> </dt> <dd> SASL password for use with the PLAIN, and SCRAM-SHA mechanisms. </dd> <dt class="optional">SSL CA location <span class="property-type">string</span> </dt> <dd> The location (on the Node-RED server) of the CA certificate(s) to use to verify the Kafka broker's key. </dd> </dl> </script> <script type="text/x-red" data-template-name="kafka-broker-secure"> <div class="form-row node-input-broker"> <label for="node-config-input-broker"><i class="icon-bookmark"></i> Broker List</label> <input class="input-append-left" type="text" id="node-config-input-broker" placeholder="localhost:9092" style="width: 40%;" > </div> <div class="form-row"> <label for="node-config-input-clientid">Client ID</label> <input type="text" id="node-config-input-clientid" placeholder="Leave blank for auto generated"> </div> <div class="form-row"> <label for="node-config-input-security_protocol">Security protocol</label> <select type="text" id="node-config-input-security_protocol"> <option value="" selected="selected"></option> <option value="plaintext">plaintext</option> <option value="ssl">ssl</option> <option value="sasl_plaintext">sasl_plaintext</option> <option value="sasl_ssl">sasl_ssl</option> </select> </div> <div class="form-row"> <label for="node-config-input-sasl_mechanism">SASL mechanism</label> <select type="text" id="node-config-input-sasl_mechanism"> <option value="" selected="selected"></option> <option value="GSSAPI">GSSAPI</option> <option value="PLAIN">PLAIN</option> <option value="SCRAM-SHA-256">SCRAM-SHA-256</option> <option value="SCRAM-SHA-512">SCRAM-SHA-512</option> </select> </div> <div class="form-row"> <label for="node-config-input-sasl_username">SASL username</label> <input class="input-append-left" type="text" id="node-config-input-sasl_username" placeholder=""> </div> <div class="form-row"> <label for="node-config-input-sasl_password">SASL password</label> <input class="input-append-left" type="text" id="node-config-input-sasl_password" placeholder=""> </div> <div class="form-row"> <label for="node-config-input-ssl_ca_location">SSL CA location</label> <input class="input-append-left" type="text" id="node-config-input-ssl_ca_location" placeholder=""> </div> <div class="form-row"> <label for="node-config-input-enable_ssl_certificate_verification">Enable SSL cert verification</label> <input class="input-append-left" type="checkbox" id="node-config-input-enable_ssl_certificate_verification"> </div> <div id="help-rdkafka-ssl-support" class="form-tips"> <b>Note:</b> SSL support is not enabled. For more information about what is required for SSL support, see the <a href="https://github.com/Blizzard/node-rdkafka#requirements" target="_blank">node-rdkafka documentation</a>. </div> </script> <script type="text/javascript"> RED.nodes.registerType('kafka-broker-secure', { category: 'config', defaults: { broker: { value:"",required:true }, clientid: { value:"" }, security_protocol: { value: "", required: false }, sasl_mechanism: { value: "", required: false }, ssl_ca_location: { value: "", required: false }, enable_ssl_certificate_verification: { value: true } }, credentials: { sasl_username: { type: "text" }, sasl_password: { type: "password" } }, label: function() { if (this.broker == "") { this.broker = "localhost:9092"; } return (this.clientid?this.clientid+"@":"")+this.broker; }, oneditprepare: function() { $.getJSON('rdkafka',function(data) { if (data && data.features && data.features.indexOf('ssl') >= 0) { // rdkafka has been built with SSL support $("#help-rdkafka-ssl-support").hide(); $("#node-config-input-ssl_ca_location").prop("disabled", false); $("#node-config-input-enable_ssl_certificate_verification").prop("disabled", false); $("#node-config-input-security_protocol").children('option[value="ssl"]').removeAttr("disabled"); $("#node-config-input-security_protocol").children('option[value="sasl_ssl"]').removeAttr("disabled"); } else { // rdkafka is missing SSL support $("#help-rdkafka-ssl-support").show(); $("#node-config-input-ssl_ca_location").val(""); $("#node-config-input-enable_ssl_certificate_verification").prop("disabled", true); $("#node-config-input-ssl_ca_location").prop("disabled", true); $("#node-config-input-security_protocol").children('option[value="ssl"]').attr("disabled", ""); $("#node-config-input-security_protocol").children('option[value="sasl_ssl"]').attr("disabled", ""); } }); } }); </script>