Skip to content

Commit

Permalink
Merge pull request #39 from mojaloop/kafka-auth
Browse files Browse the repository at this point in the history
feat(nodejs-kafka-client-lib): Added authentication to kafka client (protocol config)
  • Loading branch information
pedrosousabarreto authored May 21, 2024
2 parents 07028ca + 9a59dfa commit 3471c5d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/nodejs-kafka-client-lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import {MLKafkaJsonProducer, MLKafkaJsonProducerOptions} from "@mojaloop/platfor
const logger: ConsoleLogger = new ConsoleLogger();

const authOptions: IRawAuthenticationOptions = {
protocol: "sasl_plaintext",
mechanism: "SCRAM-SHA-256",
username: "kafka",
password: "password"
Expand Down
1 change: 1 addition & 0 deletions packages/nodejs-kafka-client-lib/src/raw/raw_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export declare interface IRawMessageProducer {
}

export declare interface IRawAuthenticationOptions {
protocol: "plaintext" | "ssl" | "sasl_plaintext" | "sasl_ssl";
mechanism: "PLAIN" | "GSSAPI" | "SCRAM-SHA-256" | "SCRAM-SHA-512",
username: string,
password: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export class MLKafkaRawConsumer extends EventEmitter implements IRawMessageConsu

// authentication options
if(this._options.authentication != undefined) {
this._globalConfig["security.protocol"] = this._options.authentication.protocol;
this._globalConfig["sasl.mechanism"] = this._options.authentication.mechanism;
this._globalConfig["sasl.username"] = this._options.authentication.username;
this._globalConfig["sasl.password"] = this._options.authentication.password;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export class MLKafkaRawProducer extends EventEmitter implements IRawMessageProdu

// authentication options
if(this._options.authentication != undefined) {
this._globalConfig["security.protocol"] = this._options.authentication.protocol;
this._globalConfig["sasl.mechanism"] = this._options.authentication.mechanism;
this._globalConfig["sasl.username"] = this._options.authentication.username;
this._globalConfig["sasl.password"] = this._options.authentication.password;
Expand Down

0 comments on commit 3471c5d

Please sign in to comment.