ldap-rest 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/abstract/ldapFlat.js +1 -1
  2. package/dist/bin/index.js +1 -1
  3. package/dist/config/args.js +1 -1
  4. package/dist/lib/expressFormatedResponses.js +1 -1
  5. package/dist/lib/ldapActions.js +1 -1
  6. package/dist/lib/utils.js +1 -1
  7. package/dist/plugins/auth/token.js +1 -1
  8. package/dist/plugins/ldap/groups.js +1 -1
  9. package/dist/plugins/ldap/organization.js +1 -1
  10. package/dist/plugins/ldap/passwordPolicy.js +1 -0
  11. package/dist/plugins/twake/calendarResources.js +1 -1
  12. package/dist/plugins/twake/james.js +1 -1
  13. package/dist/src/abstract/ldapFlat.d.ts +0 -9
  14. package/dist/src/config/args.d.ts +9 -0
  15. package/dist/src/lib/ldapActions.d.ts +2 -0
  16. package/dist/src/lib/parseConfig.d.ts +1 -2
  17. package/dist/src/lib/utils.d.ts +34 -0
  18. package/dist/src/plugins/ldap/groups.d.ts +0 -9
  19. package/dist/src/plugins/ldap/passwordPolicy.d.ts +70 -0
  20. package/dist/src/plugins/twake/calendarResources.d.ts +9 -0
  21. package/dist/src/plugins/twake/james.d.ts +8 -0
  22. package/docs/presentations/en.md +2 -2
  23. package/docs/presentations/fr.md +2 -2
  24. package/docs/usage/plugins/integrations/calendar-resources.md +43 -0
  25. package/docs/usage/plugins/integrations/james-mail.md +238 -0
  26. package/docs/usage/plugins/ldap/README.md +21 -9
  27. package/docs/usage/plugins/ldap/password-policy.md +454 -0
  28. package/package.json +201 -163
  29. package/static/schemas/standard/automountMaps.json +37 -0
  30. package/static/schemas/standard/dhcpHosts.json +52 -0
  31. package/static/schemas/standard/dnsRecords.json +102 -0
  32. package/static/schemas/standard/netgroups.json +48 -0
  33. package/static/schemas/standard/posixAccounts.json +92 -0
  34. package/static/schemas/standard/posixGroups.json +49 -0
  35. package/static/schemas/standard/sshPublicKeys.json +49 -0
  36. package/static/schemas/standard/sudoRules.json +87 -0
@@ -17,15 +17,6 @@ export default class LdapGroups extends DmPlugin {
17
17
  ldap: ldapActions;
18
18
  cn: string;
19
19
  schema?: Schema;
20
- private regexCache;
21
- /**
22
- * Get a compiled RegExp from cache, or compile and cache it
23
- */
24
- private getCompiledRegex;
25
- /**
26
- * Escape special regex characters in a string
27
- */
28
- private escapeRegex;
29
20
  constructor(server: DM);
30
21
  /**
31
22
  * Catch all deletion to remove deleted users from groups
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Password Policy plugin - Administration API for OpenLDAP ppolicy
3
+ *
4
+ * Provides REST endpoints to:
5
+ * - Query password status (expiration, lockout, etc.)
6
+ * - Unlock locked accounts
7
+ * - List expiring passwords and locked accounts
8
+ * - Validate password complexity (optional)
9
+ *
10
+ * @author Xavier Guimard <xguimard@linagora.com>
11
+ */
12
+ import type { Express } from 'express';
13
+ import DmPlugin, { type Role } from '../../abstract/plugin';
14
+ export default class PasswordPolicy extends DmPlugin {
15
+ name: string;
16
+ roles: Role[];
17
+ private policyCache;
18
+ private policyCacheTime;
19
+ private readonly POLICY_CACHE_TTL;
20
+ api(app: Express): void;
21
+ /**
22
+ * Get password status for a user
23
+ */
24
+ private getPasswordStatus;
25
+ /**
26
+ * Calculate password status from LDAP entry and policy
27
+ */
28
+ private calculateStatus;
29
+ /**
30
+ * Unlock a user account by removing pwdAccountLockedTime and pwdFailureTime
31
+ */
32
+ private unlockAccount;
33
+ /**
34
+ * Find users with passwords expiring soon
35
+ */
36
+ private findExpiringPasswords;
37
+ /**
38
+ * Find locked accounts
39
+ */
40
+ private findLockedAccounts;
41
+ /**
42
+ * Read ppolicy configuration from LDAP
43
+ */
44
+ private readPolicyConfig;
45
+ /**
46
+ * Parse ppolicy entry to config object
47
+ */
48
+ private parsePolicyEntry;
49
+ /**
50
+ * Parse number from LDAP attribute value
51
+ */
52
+ private parseNumber;
53
+ /**
54
+ * Parse GeneralizedTime (YYYYMMDDHHmmssZ) to Date
55
+ */
56
+ private parseGeneralizedTime;
57
+ /**
58
+ * Validate password complexity (optional local validation)
59
+ */
60
+ private validateComplexity;
61
+ /**
62
+ * Resolve user DN from userId (uid or full DN)
63
+ * Escapes special characters in userId to prevent LDAP injection
64
+ */
65
+ private resolveUserDn;
66
+ /**
67
+ * Provide configuration data for config API
68
+ */
69
+ getConfigApiData(): Record<string, unknown> | undefined;
70
+ }
@@ -28,4 +28,13 @@ export default class CalendarResources extends TwakePlugin {
28
28
  * Extract resource ID from DN
29
29
  */
30
30
  private getResourceId;
31
+ /**
32
+ * Delete user data from Twake Calendar WebAdmin API
33
+ * Calls POST /users/{mail}?action=deleteData
34
+ * @param mail - The user's email address
35
+ * @returns Task information or null on error
36
+ */
37
+ deleteUserData(mail: string): Promise<{
38
+ taskId: string;
39
+ } | null>;
31
40
  }
@@ -39,6 +39,14 @@ export default class James extends TwakePlugin {
39
39
  getDisplayNameFromDN(dn: string): Promise<string | null>;
40
40
  generateSignature(dn: string): Promise<string | null>;
41
41
  updateJamesIdentity(dn: string, mail: string, displayName: string): Promise<void>;
42
+ /**
43
+ * Delete user data via James WebAdmin API
44
+ * Calls POST /users/{mail}?action=deleteData
45
+ * Returns task information from the response
46
+ */
47
+ deleteUserData(mail: string, fromStep?: string): Promise<{
48
+ taskId: string;
49
+ } | null>;
42
50
  /**
43
51
  * Type guard to check if delete operation is an AttributesList
44
52
  */
@@ -7,7 +7,7 @@ sub_title: Lightweight Directory Manager
7
7
 
8
8
  ## Lightweight Directory Manager with Plugin Architecture
9
9
 
10
- ![LDAP-Rest Logo](./linagora.png)
10
+ ![LDAP-Rest Logo](../linagora.png)
11
11
 
12
12
  <!-- end_slide -->
13
13
 
@@ -710,7 +710,7 @@ Open http://localhost:8081
710
710
 
711
711
  ## LDAP-Rest - Lightweight Directory Manager
712
712
 
713
- [![Powered by LINAGORA](./linagora.png)](https://linagora.com)
713
+ [![Powered by LINAGORA](../linagora.png)](https://linagora.com)
714
714
 
715
715
  **GitHub**: https://github.com/linagora/ldap-rest
716
716
 
@@ -7,7 +7,7 @@ sub_title: Gestionnaire d'annuaire léger avec architecture à plugins
7
7
 
8
8
  ## Gestionnaire d'annuaire léger avec architecture à plugins
9
9
 
10
- ![LDAP-Rest Logo](./linagora.png)
10
+ ![LDAP-Rest Logo](../linagora.png)
11
11
 
12
12
  <!-- end_slide -->
13
13
 
@@ -710,7 +710,7 @@ Ouvrez http://localhost:8081
710
710
 
711
711
  ## LDAP-Rest - Gestionnaire d'annuaire léger
712
712
 
713
- [![Powered by LINAGORA](./linagora.png)](https://linagora.com)
713
+ [![Powered by LINAGORA](../linagora.png)](https://linagora.com)
714
714
 
715
715
  **GitHub**: https://github.com/linagora/ldap-rest
716
716
 
@@ -146,3 +146,46 @@ Ensure `DM_CALENDAR_WEBADMIN_TOKEN` is set and valid. The token is sent as a Bea
146
146
  ### Wrong resources being synced
147
147
 
148
148
  Use `DM_CALENDAR_RESOURCE_BASE` and `DM_CALENDAR_RESOURCE_OBJECTCLASS` to filter which LDAP entries are considered resources.
149
+
150
+ ## Public Methods
151
+
152
+ Public methods available on the CalendarResources plugin instance.
153
+
154
+ ### Usage
155
+
156
+ ```typescript
157
+ import type { DM } from 'ldap-rest';
158
+ import type CalendarResources from 'ldap-rest/plugin-twake-calendarresources';
159
+
160
+ // Get the plugin instance from another plugin
161
+ const calendar = this.server.getPlugin(
162
+ 'calendarResources'
163
+ ) as CalendarResources;
164
+ ```
165
+
166
+ ### deleteUserData(mail)
167
+
168
+ Delete all user data from Twake Calendar via WebAdmin API. Useful for GDPR "right to be forgotten" compliance.
169
+
170
+ **Signature:**
171
+
172
+ ```typescript
173
+ async deleteUserData(mail: string): Promise<{ taskId: string } | null>
174
+ ```
175
+
176
+ **Parameters:**
177
+
178
+ - `mail` (string): User's email address
179
+
180
+ **Returns:** Task information with `taskId`, or `null` on error.
181
+
182
+ **Example:**
183
+
184
+ ```typescript
185
+ const result = await calendar.deleteUserData('user@example.com');
186
+ if (result) {
187
+ console.log(`Deletion task started: ${result.taskId}`);
188
+ }
189
+ ```
190
+
191
+ **Reference:** [Twake Calendar deleteData API](https://github.com/linagora/twake-calendar-side-service/blob/main/docs/apis/webadmin.md#deleting-user-data)
@@ -303,6 +303,244 @@ curl http://localhost:8081/api/v1/users/jdoe/quota-usage \
303
303
  -H "Authorization: Bearer admin-token"
304
304
  ```
305
305
 
306
+ ## Public Methods
307
+
308
+ Public methods available on the James plugin instance. Useful for building GDPR workflows, custom integrations, or calling from other plugins.
309
+
310
+ ### Usage
311
+
312
+ ```typescript
313
+ import type { DM } from 'ldap-rest';
314
+ import type James from 'ldap-rest/plugin-twake-james';
315
+
316
+ // Get the James plugin instance
317
+ const james = server.getPlugin('james') as James;
318
+ ```
319
+
320
+ ### deleteUserData(mail, fromStep?)
321
+
322
+ Delete all user data via James WebAdmin API. Useful for GDPR "right to be forgotten" compliance.
323
+
324
+ **Signature:**
325
+
326
+ ```typescript
327
+ async deleteUserData(mail: string, fromStep?: string): Promise<{ taskId: string } | null>
328
+ ```
329
+
330
+ **Parameters:**
331
+
332
+ - `mail` (string): User's email address
333
+ - `fromStep` (string, optional): Resume deletion from a specific step if a previous attempt failed
334
+
335
+ **Returns:** Task information with `taskId`, or `null` on error.
336
+
337
+ **Example:**
338
+
339
+ ```typescript
340
+ const result = await james.deleteUserData('user@example.com');
341
+ if (result) {
342
+ console.log(`Deletion task started: ${result.taskId}`);
343
+ }
344
+
345
+ // Resume from a failed step
346
+ const resumed = await james.deleteUserData(
347
+ 'user@example.com',
348
+ 'DeleteMailboxesStep'
349
+ );
350
+ ```
351
+
352
+ **Reference:** [James deleteData API](https://james.apache.org/server/manage-webadmin.html#delete-data-of-a-user)
353
+
354
+ ---
355
+
356
+ ### getMailFromDN(dn)
357
+
358
+ Retrieve the email address for a user given their LDAP DN.
359
+
360
+ **Signature:**
361
+
362
+ ```typescript
363
+ async getMailFromDN(dn: string): Promise<string | null>
364
+ ```
365
+
366
+ **Parameters:**
367
+
368
+ - `dn` (string): LDAP Distinguished Name of the user
369
+
370
+ **Returns:** Email address string, or `null` if not found.
371
+
372
+ **Example:**
373
+
374
+ ```typescript
375
+ const mail = await james.getMailFromDN('uid=jdoe,ou=users,dc=example,dc=com');
376
+ // Returns: "jdoe@example.com"
377
+ ```
378
+
379
+ ---
380
+
381
+ ### getDisplayNameFromDN(dn)
382
+
383
+ Retrieve the display name for a user given their LDAP DN. Uses fallback logic: `displayName` → `cn` → `givenName sn` → `mail`.
384
+
385
+ **Signature:**
386
+
387
+ ```typescript
388
+ async getDisplayNameFromDN(dn: string): Promise<string | null>
389
+ ```
390
+
391
+ **Parameters:**
392
+
393
+ - `dn` (string): LDAP Distinguished Name of the user
394
+
395
+ **Returns:** Display name string, or `null` if not found.
396
+
397
+ **Example:**
398
+
399
+ ```typescript
400
+ const name = await james.getDisplayNameFromDN(
401
+ 'uid=jdoe,ou=users,dc=example,dc=com'
402
+ );
403
+ // Returns: "John Doe"
404
+ ```
405
+
406
+ ---
407
+
408
+ ### generateSignature(dn)
409
+
410
+ Generate an HTML email signature for a user using the configured template (`--james-signature-template`).
411
+
412
+ **Signature:**
413
+
414
+ ```typescript
415
+ async generateSignature(dn: string): Promise<string | null>
416
+ ```
417
+
418
+ **Parameters:**
419
+
420
+ - `dn` (string): LDAP Distinguished Name of the user
421
+
422
+ **Returns:** HTML signature string with placeholders replaced, or `null` if no template configured.
423
+
424
+ **Example:**
425
+
426
+ ```typescript
427
+ // With template: "<p>{displayName}</p><p>{title} - {department}</p>"
428
+ const signature = await james.generateSignature(
429
+ 'uid=jdoe,ou=users,dc=example,dc=com'
430
+ );
431
+ // Returns: "<p>John Doe</p><p>Engineer - IT</p>"
432
+ ```
433
+
434
+ ---
435
+
436
+ ### updateJamesIdentity(dn, mail, displayName)
437
+
438
+ Update a user's JMAP identity in James (name and optional signature).
439
+
440
+ **Signature:**
441
+
442
+ ```typescript
443
+ async updateJamesIdentity(dn: string, mail: string, displayName: string): Promise<void>
444
+ ```
445
+
446
+ **Parameters:**
447
+
448
+ - `dn` (string): LDAP Distinguished Name (used for signature generation)
449
+ - `mail` (string): User's email address
450
+ - `displayName` (string): New display name for the identity
451
+
452
+ **Example:**
453
+
454
+ ```typescript
455
+ await james.updateJamesIdentity(
456
+ 'uid=jdoe,ou=users,dc=example,dc=com',
457
+ 'jdoe@example.com',
458
+ 'John Doe'
459
+ );
460
+ ```
461
+
462
+ ---
463
+
464
+ ### getMemberEmails(memberDns)
465
+
466
+ Retrieve email addresses for multiple LDAP members. Useful for bulk operations on groups.
467
+
468
+ **Signature:**
469
+
470
+ ```typescript
471
+ async getMemberEmails(memberDns: string[]): Promise<string[]>
472
+ ```
473
+
474
+ **Parameters:**
475
+
476
+ - `memberDns` (string[]): Array of LDAP Distinguished Names
477
+
478
+ **Returns:** Array of email addresses (excludes members without mail attribute).
479
+
480
+ **Example:**
481
+
482
+ ```typescript
483
+ const emails = await james.getMemberEmails([
484
+ 'uid=alice,ou=users,dc=example,dc=com',
485
+ 'uid=bob,ou=users,dc=example,dc=com',
486
+ ]);
487
+ // Returns: ["alice@example.com", "bob@example.com"]
488
+ ```
489
+
490
+ ---
491
+
492
+ ### getGroupMail(groupDn)
493
+
494
+ Retrieve the email address for a group given its LDAP DN.
495
+
496
+ **Signature:**
497
+
498
+ ```typescript
499
+ async getGroupMail(groupDn: string): Promise<string | null>
500
+ ```
501
+
502
+ **Parameters:**
503
+
504
+ - `groupDn` (string): LDAP Distinguished Name of the group
505
+
506
+ **Returns:** Group email address, or `null` if not found.
507
+
508
+ **Example:**
509
+
510
+ ```typescript
511
+ const mail = await james.getGroupMail(
512
+ 'cn=engineering,ou=groups,dc=example,dc=com'
513
+ );
514
+ // Returns: "engineering@example.com"
515
+ ```
516
+
517
+ ---
518
+
519
+ ### getGroupMailboxType(groupDn)
520
+
521
+ Retrieve the mailbox type for a group (mailing list, team mailbox, or simple group).
522
+
523
+ **Signature:**
524
+
525
+ ```typescript
526
+ async getGroupMailboxType(groupDn: string): Promise<'group' | 'mailingList' | 'teamMailbox' | null>
527
+ ```
528
+
529
+ **Parameters:**
530
+
531
+ - `groupDn` (string): LDAP Distinguished Name of the group
532
+
533
+ **Returns:** Mailbox type string, or `null` if not determinable.
534
+
535
+ **Example:**
536
+
537
+ ```typescript
538
+ const type = await james.getGroupMailboxType(
539
+ 'cn=engineering,ou=groups,dc=example,dc=com'
540
+ );
541
+ // Returns: "mailingList" or "teamMailbox" or "group"
542
+ ```
543
+
306
544
  ## James WebAdmin API
307
545
 
308
546
  ### Endpoints Used
@@ -4,15 +4,16 @@ Plugins for LDAP entity management.
4
4
 
5
5
  ## Overview
6
6
 
7
- | Plugin | Entity | Features |
8
- | ----------------------------------- | ------------------------ | ----------------------------------- |
9
- | [flat-generic](flat-generic.md) | Users, Positions, Custom | Schema-driven, Validation, Pointers |
10
- | [groups](groups.md) | Groups | Member validation, Nested groups |
11
- | [organizations](organizations.md) | Organizational Units | Tree navigation, Search |
12
- | [bulk-import](bulk-import.md) | All (bulk operations) | CSV import, Template generation |
13
- | [trash](trash.md) | All (soft delete) | Trash system, Recovery |
14
- | [external-users](external-users.md) | Contacts | Automatic creation |
15
- | [on-change](on-change.md) | All | Change detection |
7
+ | Plugin | Entity | Features |
8
+ | ------------------------------------- | ------------------------ | ----------------------------------- |
9
+ | [flat-generic](flat-generic.md) | Users, Positions, Custom | Schema-driven, Validation, Pointers |
10
+ | [groups](groups.md) | Groups | Member validation, Nested groups |
11
+ | [organizations](organizations.md) | Organizational Units | Tree navigation, Search |
12
+ | [bulk-import](bulk-import.md) | All (bulk operations) | CSV import, Template generation |
13
+ | [trash](trash.md) | All (soft delete) | Trash system, Recovery |
14
+ | [external-users](external-users.md) | Contacts | Automatic creation |
15
+ | [on-change](on-change.md) | All | Change detection |
16
+ | [password-policy](password-policy.md) | Password management | Expiration, Lockout, Unlock |
16
17
 
17
18
  ## API Endpoints
18
19
 
@@ -50,6 +51,17 @@ POST /api/v1/ldap/organizations/{dn}/move # Move
50
51
  DELETE /api/v1/ldap/organizations/{dn} # Delete
51
52
  ```
52
53
 
54
+ ### Password Policy (passwordPolicy)
55
+
56
+ ```
57
+ GET /api/v1/password-policy # Get ppolicy configuration
58
+ GET /api/v1/users/{id}/password-status # Get user password status
59
+ POST /api/v1/users/{id}/unlock # Unlock locked account
60
+ GET /api/v1/password-policy/expiring-soon # List expiring passwords
61
+ GET /api/v1/password-policy/locked-accounts # List locked accounts
62
+ POST /api/v1/password/validate # Validate complexity (optional)
63
+ ```
64
+
53
65
  ### Bulk Import (ldapBulkImport)
54
66
 
55
67
  ```