mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00: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:
@@ -28,10 +28,23 @@ export class Kafka implements ICredentialType {
|
|||||||
type: 'boolean' as NodePropertyTypes,
|
type: 'boolean' as NodePropertyTypes,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Authentication',
|
||||||
|
name: 'authentication',
|
||||||
|
type: 'boolean' as NodePropertyTypes,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Username',
|
displayName: 'Username',
|
||||||
name: 'username',
|
name: 'username',
|
||||||
type: 'string' as NodePropertyTypes,
|
type: 'string' as NodePropertyTypes,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
authentication: [
|
||||||
|
true,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
default: '',
|
default: '',
|
||||||
description: 'Optional username if authenticated is required.',
|
description: 'Optional username if authenticated is required.',
|
||||||
},
|
},
|
||||||
@@ -39,11 +52,46 @@ export class Kafka implements ICredentialType {
|
|||||||
displayName: 'Password',
|
displayName: 'Password',
|
||||||
name: 'password',
|
name: 'password',
|
||||||
type: 'string' as NodePropertyTypes,
|
type: 'string' as NodePropertyTypes,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
authentication: [
|
||||||
|
true,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
password: true,
|
password: true,
|
||||||
},
|
},
|
||||||
default: '',
|
default: '',
|
||||||
description: 'Optional password if authenticated is required.',
|
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,
|
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 = {
|
config.sasl = {
|
||||||
username: credentials.username as string,
|
username: credentials.username as string,
|
||||||
password: credentials.password as string,
|
password: credentials.password as string,
|
||||||
|
mechanism: credentials.saslMechanism as string,
|
||||||
} as SASLOptions;
|
} as SASLOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -123,10 +123,14 @@ export class KafkaTrigger implements INodeType {
|
|||||||
logLevel: logLevel.ERROR,
|
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 = {
|
config.sasl = {
|
||||||
username: credentials.username as string,
|
username: credentials.username as string,
|
||||||
password: credentials.password as string,
|
password: credentials.password as string,
|
||||||
|
mechanism: credentials.saslMechanism as string,
|
||||||
} as SASLOptions;
|
} as SASLOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user