Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Ldap Node): Add LDAP node #4783

Merged
merged 41 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4363794
Initial commit based on the n8n-nodes-ldap repo, Thanks Pemontto
Joffcom Nov 28, 2022
608a8e2
small updates
Joffcom Nov 29, 2022
a27a29f
improvements
Joffcom Nov 29, 2022
873761a
Merge branch 'master' of github.com:n8n-io/n8n into n8n-5432
Joffcom Nov 30, 2022
e385029
Added quick credential test
Joffcom Nov 30, 2022
8431280
started looking into AD attribute values
Joffcom Nov 30, 2022
59f8a6d
Merge branch 'master' of github.com:n8n-io/n8n into n8n-5432
Joffcom Dec 1, 2022
8ed7d55
Updated credential fields and fixed AD binary options
Joffcom Dec 1, 2022
483680b
Fixed search attributes
Joffcom Dec 1, 2022
a343197
Small tweak to DN
Joffcom Dec 1, 2022
60a158f
Merge branch 'master' of github.com:n8n-io/n8n into n8n-5432
Joffcom Dec 1, 2022
bf52204
Quick lint fix
Joffcom Dec 1, 2022
8c04cf5
Merge branch 'master' of github.com:n8n-io/n8n into n8n-5432
Joffcom Dec 5, 2022
3d3ed7f
Merge branch 'master' of github.com:n8n-io/n8n into n8n-5432
Joffcom Dec 6, 2022
ee50b24
Merge branch 'master' of github.com:n8n-io/n8n into n8n-5432
Joffcom Dec 6, 2022
359ab71
Tweaked UI from initial design review
Joffcom Dec 7, 2022
c1952dc
Merge branch 'master' of github.com:n8n-io/n8n into n8n-5432
Joffcom Dec 7, 2022
d8b380a
Made search a bit more user friendly
Joffcom Dec 14, 2022
f57ba62
Merge branch 'master' of github.com:n8n-io/n8n into n8n-5432
Joffcom Dec 14, 2022
e8ad373
fixed issues from field rename
Joffcom Dec 15, 2022
a04b790
Idea for loading attributes
Joffcom Dec 15, 2022
994b6a1
Merge branch 'master' of github.com:n8n-io/n8n into n8n-5432
Joffcom Dec 15, 2022
bf86700
removed comments
Joffcom Dec 15, 2022
7f924b1
Merge branch 'master' of github.com:n8n-io/n8n into n8n-5432
Joffcom Jan 4, 2023
9ad6a34
Lint fixes
Joffcom Jan 4, 2023
f815257
Merge branch 'master' of github.com:n8n-io/n8n into n8n-5432
Joffcom Apr 4, 2023
d47a5b1
Update wording from design review
Joffcom Apr 13, 2023
10f88f7
Merge branch 'master' of github.com:n8n-io/n8n into n8n-5432
Joffcom Apr 13, 2023
35fe436
Merge branch 'master' of github.com:n8n-io/n8n into n8n-5432
Joffcom Apr 13, 2023
21b9104
updated dn descriptions
Joffcom Apr 13, 2023
d6f1592
Merge branch 'master' of github.com:n8n-io/n8n into n8n-5432
Joffcom Apr 17, 2023
e73ecb3
Merge branch 'master' of github.com:n8n-io/n8n into n8n-5432
Joffcom Apr 19, 2023
c79a19d
update descriptions and actions
Joffcom Apr 19, 2023
e732a15
pnpm lock
Joffcom Apr 19, 2023
d535212
Merge branch 'master' of github.com:n8n-io/n8n into n8n-5432
Joffcom May 9, 2023
03f5dd8
Merge branch 'master' of github.com:n8n-io/n8n into n8n-5432
Joffcom May 10, 2023
dae6cc8
updates from review
Joffcom May 11, 2023
80e6379
Update from review
Joffcom May 15, 2023
f83c322
Merge branch 'master' of github.com:n8n-io/n8n into n8n-5432
Joffcom May 15, 2023
4232269
Removed surprise log message
Joffcom May 15, 2023
9e1258f
removed unused imports and comments
maspio May 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions packages/nodes-base/credentials/Ldap.credentials.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/* eslint-disable n8n-nodes-base/cred-class-name-unsuffixed,n8n-nodes-base/cred-class-field-name-unsuffixed,n8n-nodes-base/cred-class-field-display-name-missing-api */
import { ICredentialType, INodeProperties } from 'n8n-workflow';

export class Ldap implements ICredentialType {
name = 'ldap';

displayName = 'LDAP';

properties: INodeProperties[] = [
{
displayName: 'LDAP Server Address',
name: 'hostname',
type: 'string',
default: '',
required: true,
description: 'IP or domain of the LDAP server',
},
{
displayName: 'LDAP Server Port',
name: 'port',
type: 'string',
default: '389',
description: 'Port used to connect to the LDAP server',
},
{
displayName: 'Binding DN',
name: 'bindDN',
type: 'string',
default: '',
description: 'Distinguished Name of the user to connect as',
required: true,
},
{
displayName: 'Binding Password',
name: 'bindPassword',
type: 'string',
typeOptions: {
password: true,
},
default: '',
description: 'Password of the user provided in the Binding DN field above',
required: true,
},
{
displayName: 'Connection Security',
name: 'connectionSecurity',
type: 'options',
default: 'none',
options: [
{
name: 'None',
value: 'none',
},
{
name: 'TLS',
value: 'tls',
},
{
name: 'STARTTLS',
value: 'startTls',
},
],
},
{
displayName: 'Ignore SSL/TLS Issues',
name: 'allowUnauthorizedCerts',
type: 'boolean',
description: 'Whether to connect even if SSL/TLS certificate validation is not possible',
default: false,
displayOptions: {
hide: {
connectionSecurity: ['none'],
},
},
},
{
displayName: 'CA Certificate',
name: 'caCertificate',
typeOptions: {
alwaysOpenEditWindow: true,
},
displayOptions: {
hide: {
connectionSecurity: ['none'],
},
},
type: 'string',
default: '',
},
];
}
53 changes: 53 additions & 0 deletions packages/nodes-base/nodes/Ldap/Helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { Client } from 'ldapts';
import type { ClientOptions, Entry } from 'ldapts';
import type { ICredentialDataDecryptedObject, IDataObject } from 'n8n-workflow';
import { LoggerProxy as Logger } from 'n8n-workflow';
export const BINARY_AD_ATTRIBUTES = ['objectGUID', 'objectSid'];

const resolveEntryBinaryAttributes = (entry: Entry): Entry => {
Object.entries(entry)
.filter(([k]) => BINARY_AD_ATTRIBUTES.includes(k))
.forEach(([k]) => {
entry[k] = (entry[k] as Buffer).toString('hex');
});
return entry;
};

export const resolveBinaryAttributes = (entries: Entry[]): void => {
entries.forEach((entry) => resolveEntryBinaryAttributes(entry));
};

export async function createLdapClient(
credentials: ICredentialDataDecryptedObject,
nodeDebug?: boolean,
nodeType?: string,
nodeName?: string,
): Promise<Client> {
const protocol = credentials.connectionSecurity === 'tls' ? 'ldaps' : 'ldap';
const url = `${protocol}://${credentials.hostname}:${credentials.port}`;

const ldapOptions: ClientOptions = { url };
const tlsOptions: IDataObject = {};

if (credentials.connectionSecurity !== 'none') {
tlsOptions.rejectUnauthorized = credentials.allowUnauthorizedCerts === false;
if (credentials.caCertificate) {
tlsOptions.ca = [credentials.caCertificate as string];
}
if (credentials.connectionSecurity !== 'startTls') {
ldapOptions.tlsOptions = tlsOptions;
}
}

if (nodeDebug) {
Logger.info(
`[${nodeType} | ${nodeName}] - LDAP Options: ${JSON.stringify(ldapOptions, null, 2)}`,
);
}

const client = new Client(ldapOptions);
if (credentials.connectionSecurity === 'startTls') {
await client.startTLS(tlsOptions);
}
return client;
}
19 changes: 19 additions & 0 deletions packages/nodes-base/nodes/Ldap/Ldap.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"node": "n8n-nodes-base.ldap",
"nodeVersion": "1.0",
"codexVersion": "1.0",
"categories": ["Development", "Developer Tools"],
"resources": {
"credentialDocumentation": [
{
"url": "https://docs.n8n.io/credentials/ldap"
}
],
"primaryDocumentation": [
{
"url": "https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.ldap/"
}
]
},
"alias": ["ad", "active directory"]
}
Loading
Loading