Skip to content

Commit 4ec8707

Browse files
committed
feat: add ldap authentication type to config schema
Add LDAP auth type definition to config.schema.json and generated TypeScript types with LdapConfig interface. Signed-off-by: Kwangjin Ko <kyet@me.com>
1 parent a8b2bdd commit 4ec8707

2 files changed

Lines changed: 133 additions & 1 deletion

File tree

config.schema.json

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,90 @@
505505
},
506506
"required": ["type", "enabled", "oidcConfig"]
507507
},
508+
{
509+
"title": "LDAP Auth Config",
510+
"description": "Configuration for generic LDAP authentication using ldapts.",
511+
"properties": {
512+
"type": { "type": "string", "const": "ldap" },
513+
"enabled": { "type": "boolean" },
514+
"ldapConfig": {
515+
"type": "object",
516+
"description": "LDAP connection and search configuration.",
517+
"properties": {
518+
"url": {
519+
"type": "string",
520+
"description": "LDAP server URL, e.g. `ldap://ldap.example.com` or `ldaps://ldap.example.com`."
521+
},
522+
"bindDN": {
523+
"type": "string",
524+
"description": "DN of the service account used to search for users, e.g. `cn=admin,dc=example,dc=com`."
525+
},
526+
"bindPassword": {
527+
"type": "string",
528+
"description": "Password for the service account."
529+
},
530+
"searchBase": {
531+
"type": "string",
532+
"description": "Base DN for user searches, e.g. `ou=people,dc=example,dc=com`."
533+
},
534+
"searchFilter": {
535+
"type": "string",
536+
"description": "LDAP search filter template. Use `{{username}}` as a placeholder for the login username. e.g. `(uid={{username}})`."
537+
},
538+
"userGroupDN": {
539+
"type": "string",
540+
"description": "DN of the group a user must belong to in order to log in."
541+
},
542+
"adminGroupDN": {
543+
"type": "string",
544+
"description": "DN of the admin group. Members of this group are granted admin privileges."
545+
},
546+
"groupSearchBase": {
547+
"type": "string",
548+
"description": "Base DN for group membership searches. If omitted, each group's own DN (`userGroupDN` or `adminGroupDN`) is used as the search base."
549+
},
550+
"groupSearchFilter": {
551+
"type": "string",
552+
"description": "LDAP filter for group membership checks. Use `{{dn}}` as a placeholder for the user's DN. Defaults to `(member={{dn}})`."
553+
},
554+
"usernameAttribute": {
555+
"type": "string",
556+
"description": "LDAP attribute to use as the username. Defaults to `uid`."
557+
},
558+
"emailAttribute": {
559+
"type": "string",
560+
"description": "LDAP attribute for the user's email. Defaults to `mail`."
561+
},
562+
"displayNameAttribute": {
563+
"type": "string",
564+
"description": "LDAP attribute for the user's display name. Defaults to `cn`."
565+
},
566+
"titleAttribute": {
567+
"type": "string",
568+
"description": "LDAP attribute for the user's title. Defaults to `title`."
569+
},
570+
"starttls": {
571+
"type": "boolean",
572+
"description": "Use STARTTLS to upgrade an ldap:// connection to TLS. Defaults to false."
573+
},
574+
"tlsOptions": {
575+
"type": "object",
576+
"description": "Node.js TLS options passed to the ldapts client (e.g. `rejectUnauthorized`, `ca`)."
577+
}
578+
},
579+
"required": [
580+
"url",
581+
"bindDN",
582+
"bindPassword",
583+
"searchBase",
584+
"searchFilter",
585+
"userGroupDN",
586+
"adminGroupDN"
587+
]
588+
}
589+
},
590+
"required": ["type", "enabled", "ldapConfig"]
591+
},
508592
{
509593
"title": "JWT Auth Config",
510594
"description": "Configuration for JWT authentication.",

src/config/generated/config.ts

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ export interface AuthenticationElement {
190190
* Additional JWT configuration.
191191
*/
192192
jwtConfig?: JwtConfig;
193+
/**
194+
* LDAP connection and search configuration.
195+
*/
196+
ldapConfig?: LdapConfig;
193197
[property: string]: any;
194198
}
195199

@@ -253,9 +257,32 @@ export interface OidcConfig {
253257
[property: string]: any;
254258
}
255259

260+
/**
261+
* LDAP connection and search configuration.
262+
*/
263+
export interface LdapConfig {
264+
url: string;
265+
bindDN: string;
266+
bindPassword: string;
267+
searchBase: string;
268+
searchFilter: string;
269+
userGroupDN: string;
270+
adminGroupDN: string;
271+
groupSearchBase?: string;
272+
groupSearchFilter?: string;
273+
usernameAttribute?: string;
274+
emailAttribute?: string;
275+
displayNameAttribute?: string;
276+
titleAttribute?: string;
277+
starttls?: boolean;
278+
tlsOptions?: { [key: string]: any };
279+
[property: string]: any;
280+
}
281+
256282
export enum AuthenticationElementType {
257283
ActiveDirectory = 'ActiveDirectory',
258284
Jwt = 'jwt',
285+
Ldap = 'ldap',
259286
Local = 'local',
260287
Openidconnect = 'openidconnect',
261288
}
@@ -811,6 +838,7 @@ const typeMap: any = {
811838
{ json: 'userGroup', js: 'userGroup', typ: u(undefined, '') },
812839
{ json: 'oidcConfig', js: 'oidcConfig', typ: u(undefined, r('OidcConfig')) },
813840
{ json: 'jwtConfig', js: 'jwtConfig', typ: u(undefined, r('JwtConfig')) },
841+
{ json: 'ldapConfig', js: 'ldapConfig', typ: u(undefined, r('LdapConfig')) },
814842
],
815843
'any',
816844
),
@@ -844,6 +872,26 @@ const typeMap: any = {
844872
],
845873
'any',
846874
),
875+
LdapConfig: o(
876+
[
877+
{ json: 'url', js: 'url', typ: '' },
878+
{ json: 'bindDN', js: 'bindDN', typ: '' },
879+
{ json: 'bindPassword', js: 'bindPassword', typ: '' },
880+
{ json: 'searchBase', js: 'searchBase', typ: '' },
881+
{ json: 'searchFilter', js: 'searchFilter', typ: '' },
882+
{ json: 'userGroupDN', js: 'userGroupDN', typ: '' },
883+
{ json: 'adminGroupDN', js: 'adminGroupDN', typ: '' },
884+
{ json: 'groupSearchBase', js: 'groupSearchBase', typ: u(undefined, '') },
885+
{ json: 'groupSearchFilter', js: 'groupSearchFilter', typ: u(undefined, '') },
886+
{ json: 'usernameAttribute', js: 'usernameAttribute', typ: u(undefined, '') },
887+
{ json: 'emailAttribute', js: 'emailAttribute', typ: u(undefined, '') },
888+
{ json: 'displayNameAttribute', js: 'displayNameAttribute', typ: u(undefined, '') },
889+
{ json: 'titleAttribute', js: 'titleAttribute', typ: u(undefined, '') },
890+
{ json: 'starttls', js: 'starttls', typ: u(undefined, true) },
891+
{ json: 'tlsOptions', js: 'tlsOptions', typ: u(undefined, m('any')) },
892+
],
893+
'any',
894+
),
847895
AttestationConfig: o(
848896
[{ json: 'questions', js: 'questions', typ: u(undefined, a(r('Question'))) }],
849897
false,
@@ -981,6 +1029,6 @@ const typeMap: any = {
9811029
],
9821030
'any',
9831031
),
984-
AuthenticationElementType: ['ActiveDirectory', 'jwt', 'local', 'openidconnect'],
1032+
AuthenticationElementType: ['ActiveDirectory', 'jwt', 'ldap', 'local', 'openidconnect'],
9851033
DatabaseType: ['fs', 'mongo'],
9861034
};

0 commit comments

Comments
 (0)