mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 04:04:06 -08:00
⚡ Add SASL mechanism option in Kafka (#1525)
* ⚡ add SASL mechasnim option in Kafka * add toggle for authentication in kafka credentials * ⚡ Revery default value Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
parent
0712334679
commit
71e21c2dae
|
@ -28,10 +28,23 @@ export class Kafka implements ICredentialType {
|
|||
type: 'boolean' as NodePropertyTypes,
|
||||
default: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Authentication',
|
||||
name: 'authentication',
|
||||
type: 'boolean' as NodePropertyTypes,
|
||||
default: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Username',
|
||||
name: 'username',
|
||||
type: 'string' as NodePropertyTypes,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
true,
|
||||
],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Optional username if authenticated is required.',
|
||||
},
|
||||
|
@ -39,11 +52,46 @@ export class Kafka implements ICredentialType {
|
|||
displayName: 'Password',
|
||||
name: 'password',
|
||||
type: 'string' as NodePropertyTypes,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
true,
|
||||
],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
password: true,
|
||||
},
|
||||
default: '',
|
||||
description: 'Optional password if authenticated is required.',
|
||||
},
|
||||
{
|
||||
displayName: 'SASL mechanism',
|
||||
name: 'saslMechanism',
|
||||
type: 'options' as NodePropertyTypes,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
true,
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'plain',
|
||||
value: 'plain',
|
||||
},
|
||||
{
|
||||
name: 'scram-sha-256',
|
||||
value: 'scram-sha-256',
|
||||
},
|
||||
{
|
||||
name: 'scram-sha-512',
|
||||
value: 'scram-sha-512',
|
||||
},
|
||||
],
|
||||
default: 'plain',
|
||||
description: 'The SASL mechanism.',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
|
@ -193,10 +193,14 @@ export class Kafka implements INodeType {
|
|||
ssl,
|
||||
};
|
||||
|
||||
if (credentials.username || credentials.password) {
|
||||
if (credentials.authentication === true) {
|
||||
if(!(credentials.username && credentials.password)) {
|
||||
throw new Error('Username and password are required for authentication');
|
||||
}
|
||||
config.sasl = {
|
||||
username: credentials.username as string,
|
||||
password: credentials.password as string,
|
||||
mechanism: credentials.saslMechanism as string,
|
||||
} as SASLOptions;
|
||||
}
|
||||
|
||||
|
|
|
@ -123,10 +123,14 @@ export class KafkaTrigger implements INodeType {
|
|||
logLevel: logLevel.ERROR,
|
||||
};
|
||||
|
||||
if (credentials.username || credentials.password) {
|
||||
if (credentials.authentication === true) {
|
||||
if(!(credentials.username && credentials.password)) {
|
||||
throw new Error('Username and password are required for authentication');
|
||||
}
|
||||
config.sasl = {
|
||||
username: credentials.username as string,
|
||||
password: credentials.password as string,
|
||||
mechanism: credentials.saslMechanism as string,
|
||||
} as SASLOptions;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue