ldap-rest 0.0.1
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.
- package/LICENSE +661 -0
- package/README.md +48 -0
- package/bin/cleanup-external-users.mjs +219 -0
- package/bin/index.mjs +54 -0
- package/bin/sync-james.mjs +190 -0
- package/dist/abstract/ldapFlat.js +1 -0
- package/dist/abstract/plugin.js +1 -0
- package/dist/abstract/twakePlugin.js +1 -0
- package/dist/bin/index.js +1 -0
- package/dist/config/args.js +1 -0
- package/dist/lib/auth/base.js +1 -0
- package/dist/lib/authz/base.js +1 -0
- package/dist/lib/expressFormatedResponses.js +1 -0
- package/dist/lib/ldapActions.js +1 -0
- package/dist/lib/parseConfig.js +1 -0
- package/dist/lib/utils.js +1 -0
- package/dist/logger/winston.js +1 -0
- package/dist/plugins/auth/authzLinid1.js +1 -0
- package/dist/plugins/auth/authzPerBranch.js +1 -0
- package/dist/plugins/auth/crowdsec.js +1 -0
- package/dist/plugins/auth/llng.js +1 -0
- package/dist/plugins/auth/openidconnect.js +1 -0
- package/dist/plugins/auth/rateLimit.js +1 -0
- package/dist/plugins/auth/token.js +1 -0
- package/dist/plugins/configApi.js +1 -0
- package/dist/plugins/demo/helloworld.js +1 -0
- package/dist/plugins/ldap/bulkImport.js +1 -0
- package/dist/plugins/ldap/departmentSync.js +1 -0
- package/dist/plugins/ldap/externalUsersInGroups.js +1 -0
- package/dist/plugins/ldap/flatGeneric.js +1 -0
- package/dist/plugins/ldap/groups.js +1 -0
- package/dist/plugins/ldap/onChange.js +1 -0
- package/dist/plugins/ldap/organization.js +1 -0
- package/dist/plugins/ldap/trash.js +1 -0
- package/dist/plugins/priority.json.js +1 -0
- package/dist/plugins/static.js +1 -0
- package/dist/plugins/twake/calendarResources.js +1 -0
- package/dist/plugins/twake/james.js +1 -0
- package/dist/plugins/weblogs.js +1 -0
- package/dist/src/abstract/ldapFlat.d.ts +94 -0
- package/dist/src/abstract/plugin.d.ts +43 -0
- package/dist/src/abstract/twakePlugin.d.ts +90 -0
- package/dist/src/bin/index.d.ts +43 -0
- package/dist/src/browser/ldap-group-editor/LdapGroupEditor.d.ts +31 -0
- package/dist/src/browser/ldap-group-editor/api/GroupApiClient.d.ts +23 -0
- package/dist/src/browser/ldap-group-editor/components/CreateGroupModal.d.ts +19 -0
- package/dist/src/browser/ldap-group-editor/components/GroupPropertyEditor.d.ts +30 -0
- package/dist/src/browser/ldap-group-editor/components/GroupTree.d.ts +17 -0
- package/dist/src/browser/ldap-group-editor/components/MoveGroupModal.d.ts +20 -0
- package/dist/src/browser/ldap-group-editor/index.d.ts +6 -0
- package/dist/src/browser/ldap-group-editor/types.d.ts +58 -0
- package/dist/src/browser/ldap-resource-editor/api/ResourceApiClient.d.ts +53 -0
- package/dist/src/browser/ldap-resource-editor/cache/CacheManager.d.ts +65 -0
- package/dist/src/browser/ldap-resource-editor/index.d.ts +6 -0
- package/dist/src/browser/ldap-resource-editor/types.d.ts +78 -0
- package/dist/src/browser/ldap-tree-viewer/LdapTreeViewer.d.ts +26 -0
- package/dist/src/browser/ldap-tree-viewer/api/LdapApiClient.d.ts +30 -0
- package/dist/src/browser/ldap-tree-viewer/components/TreeNode.d.ts +17 -0
- package/dist/src/browser/ldap-tree-viewer/components/TreeRoot.d.ts +14 -0
- package/dist/src/browser/ldap-tree-viewer/index.d.ts +7 -0
- package/dist/src/browser/ldap-tree-viewer/store/Store.d.ts +18 -0
- package/dist/src/browser/ldap-tree-viewer/store/actions.d.ts +28 -0
- package/dist/src/browser/ldap-tree-viewer/store/reducers.d.ts +7 -0
- package/dist/src/browser/ldap-tree-viewer/types.d.ts +34 -0
- package/dist/src/browser/ldap-unit-editor/LdapUnitEditor.d.ts +27 -0
- package/dist/src/browser/ldap-unit-editor/api/UnitApiClient.d.ts +24 -0
- package/dist/src/browser/ldap-unit-editor/components/MoveUnitModal.d.ts +28 -0
- package/dist/src/browser/ldap-unit-editor/components/UnitPropertyEditor.d.ts +28 -0
- package/dist/src/browser/ldap-unit-editor/components/UnitTree.d.ts +18 -0
- package/dist/src/browser/ldap-unit-editor/index.d.ts +6 -0
- package/dist/src/browser/ldap-unit-editor/types.d.ts +55 -0
- package/dist/src/browser/ldap-user-editor/LdapUserEditor.d.ts +32 -0
- package/dist/src/browser/ldap-user-editor/api/UserApiClient.d.ts +55 -0
- package/dist/src/browser/ldap-user-editor/cache/CacheManager.d.ts +65 -0
- package/dist/src/browser/ldap-user-editor/components/MoveUserModal.d.ts +28 -0
- package/dist/src/browser/ldap-user-editor/components/PointerField.d.ts +22 -0
- package/dist/src/browser/ldap-user-editor/components/UserEditor.d.ts +46 -0
- package/dist/src/browser/ldap-user-editor/components/UserList.d.ts +24 -0
- package/dist/src/browser/ldap-user-editor/components/UserTree.d.ts +24 -0
- package/dist/src/browser/ldap-user-editor/index.d.ts +7 -0
- package/dist/src/browser/ldap-user-editor/types.d.ts +67 -0
- package/dist/src/browser/shared/components/Modal.d.ts +38 -0
- package/dist/src/browser/shared/components/StatusMessage.d.ts +48 -0
- package/dist/src/browser/shared/index.d.ts +10 -0
- package/dist/src/browser/shared/types/index.d.ts +65 -0
- package/dist/src/browser/shared/utils/dom.d.ts +33 -0
- package/dist/src/browser/shared/utils/form.d.ts +28 -0
- package/dist/src/browser/shared/utils/schema.d.ts +29 -0
- package/dist/src/config/args.d.ts +128 -0
- package/dist/src/config/schema.d.ts +18 -0
- package/dist/src/hooks.d.ts +76 -0
- package/dist/src/lib/auth/base.d.ts +9 -0
- package/dist/src/lib/authz/base.d.ts +63 -0
- package/dist/src/lib/expressFormatedResponses.d.ts +26 -0
- package/dist/src/lib/ldapActions.d.ts +91 -0
- package/dist/src/lib/parseConfig.d.ts +23 -0
- package/dist/src/lib/utils.d.ts +73 -0
- package/dist/src/logger/winston.d.ts +3 -0
- package/dist/src/plugins/auth/authzLinid1.d.ts +46 -0
- package/dist/src/plugins/auth/authzPerBranch.d.ts +59 -0
- package/dist/src/plugins/auth/crowdsec.d.ts +29 -0
- package/dist/src/plugins/auth/llng.d.ts +8 -0
- package/dist/src/plugins/auth/openidconnect.d.ts +11 -0
- package/dist/src/plugins/auth/rateLimit.d.ts +24 -0
- package/dist/src/plugins/auth/token.d.ts +17 -0
- package/dist/src/plugins/configApi.d.ts +24 -0
- package/dist/src/plugins/demo/helloworld.d.ts +12 -0
- package/dist/src/plugins/ldap/bulkImport.d.ts +48 -0
- package/dist/src/plugins/ldap/departmentSync.d.ts +35 -0
- package/dist/src/plugins/ldap/externalUsersInGroups.d.ts +21 -0
- package/dist/src/plugins/ldap/flatGeneric.d.ts +31 -0
- package/dist/src/plugins/ldap/groups.d.ts +95 -0
- package/dist/src/plugins/ldap/onChange.d.ts +32 -0
- package/dist/src/plugins/ldap/organization.d.ts +65 -0
- package/dist/src/plugins/ldap/trash.d.ts +52 -0
- package/dist/src/plugins/static.d.ts +7 -0
- package/dist/src/plugins/twake/calendarResources.d.ts +31 -0
- package/dist/src/plugins/twake/james.d.ts +83 -0
- package/dist/src/plugins/weblogs.d.ts +8 -0
- package/docs/DEVELOPER_GUIDE.md +298 -0
- package/docs/OPENAPI.md +440 -0
- package/docs/PLUGIN_DEPENDENCIES.md +612 -0
- package/docs/README.md +466 -0
- package/docs/api/REFERENCE.md +983 -0
- package/docs/api/REST_API.md +1237 -0
- package/docs/authentication.md +469 -0
- package/docs/authzLinid1.md +521 -0
- package/docs/authzPerBranch.md +596 -0
- package/docs/browser/LIBRARIES.md +1196 -0
- package/docs/examples/EXAMPLES.md +1659 -0
- package/docs/examples/twake-mailbox-type-nomenclature.ldif +37 -0
- package/docs/examples/twake-mailbox-type-schema-amendment.ldif +30 -0
- package/docs/jamesTeamMailboxes.md +343 -0
- package/docs/ldapBulkImport.md +722 -0
- package/docs/ldapExternalUsersInGroups.md +325 -0
- package/docs/ldapFlatGeneric.md +444 -0
- package/docs/ldapGroups.md +589 -0
- package/docs/ldapOrganizations.md +659 -0
- package/docs/ldapTrash.md +260 -0
- package/docs/linagora.png +0 -0
- package/docs/onChange.md +318 -0
- package/docs/plugins/DEVELOPMENT.md +1219 -0
- package/docs/presenterm-fr.md +721 -0
- package/docs/presenterm.md +721 -0
- package/docs/schemas/SCHEMAS.md +1212 -0
- package/docs/static.md +410 -0
- package/docs/twakeCalendarResources.md +148 -0
- package/docs/twakeJames.md +661 -0
- package/docs/weblogs.md +399 -0
- package/examples/web/ldap-group-editor.html +113 -0
- package/examples/web/ldap-tree-viewer.html +368 -0
- package/examples/web/ldap-unit-editor.html +108 -0
- package/examples/web/ldap-user-editor.html +412 -0
- package/package.json +458 -0
- package/static/browser/common-demo.css +450 -0
- package/static/browser/ldap-group-editor/LdapGroupEditor.js +207 -0
- package/static/browser/ldap-group-editor/LdapGroupEditor.js.map +1 -0
- package/static/browser/ldap-group-editor/api/GroupApiClient.js +112 -0
- package/static/browser/ldap-group-editor/api/GroupApiClient.js.map +1 -0
- package/static/browser/ldap-group-editor/components/CreateGroupModal.js +212 -0
- package/static/browser/ldap-group-editor/components/CreateGroupModal.js.map +1 -0
- package/static/browser/ldap-group-editor/components/GroupPropertyEditor.js +497 -0
- package/static/browser/ldap-group-editor/components/GroupPropertyEditor.js.map +1 -0
- package/static/browser/ldap-group-editor/components/GroupTree.js +153 -0
- package/static/browser/ldap-group-editor/components/GroupTree.js.map +1 -0
- package/static/browser/ldap-group-editor/components/MoveGroupModal.js +235 -0
- package/static/browser/ldap-group-editor/components/MoveGroupModal.js.map +1 -0
- package/static/browser/ldap-group-editor/index.js +2 -0
- package/static/browser/ldap-group-editor/index.js.map +1 -0
- package/static/browser/ldap-group-editor/types.js +2 -0
- package/static/browser/ldap-group-editor/types.js.map +1 -0
- package/static/browser/ldap-group-editor.esm.js +1399 -0
- package/static/browser/ldap-group-editor.esm.js.map +1 -0
- package/static/browser/ldap-group-editor.js +1407 -0
- package/static/browser/ldap-group-editor.js.map +1 -0
- package/static/browser/ldap-group-editor.min.js +2 -0
- package/static/browser/ldap-group-editor.min.js.map +1 -0
- package/static/browser/ldap-resource-editor/api/ResourceApiClient.js +226 -0
- package/static/browser/ldap-resource-editor/api/ResourceApiClient.js.map +1 -0
- package/static/browser/ldap-resource-editor/cache/CacheManager.js +123 -0
- package/static/browser/ldap-resource-editor/cache/CacheManager.js.map +1 -0
- package/static/browser/ldap-resource-editor/index.js +2 -0
- package/static/browser/ldap-resource-editor/index.js.map +1 -0
- package/static/browser/ldap-resource-editor/types.js +2 -0
- package/static/browser/ldap-resource-editor/types.js.map +1 -0
- package/static/browser/ldap-tree-viewer/LdapTreeViewer.js +187 -0
- package/static/browser/ldap-tree-viewer/LdapTreeViewer.js.map +1 -0
- package/static/browser/ldap-tree-viewer/api/LdapApiClient.js +50 -0
- package/static/browser/ldap-tree-viewer/api/LdapApiClient.js.map +1 -0
- package/static/browser/ldap-tree-viewer/components/TreeNode.js +140 -0
- package/static/browser/ldap-tree-viewer/components/TreeNode.js.map +1 -0
- package/static/browser/ldap-tree-viewer/components/TreeRoot.js +98 -0
- package/static/browser/ldap-tree-viewer/components/TreeRoot.js.map +1 -0
- package/static/browser/ldap-tree-viewer/index.js +2 -0
- package/static/browser/ldap-tree-viewer/index.js.map +1 -0
- package/static/browser/ldap-tree-viewer/store/Store.js +29 -0
- package/static/browser/ldap-tree-viewer/store/Store.js.map +1 -0
- package/static/browser/ldap-tree-viewer/store/actions.js +53 -0
- package/static/browser/ldap-tree-viewer/store/actions.js.map +1 -0
- package/static/browser/ldap-tree-viewer/store/reducers.js +79 -0
- package/static/browser/ldap-tree-viewer/store/reducers.js.map +1 -0
- package/static/browser/ldap-tree-viewer/types.js +2 -0
- package/static/browser/ldap-tree-viewer/types.js.map +1 -0
- package/static/browser/ldap-tree-viewer.css +2 -0
- package/static/browser/ldap-tree-viewer.css.map +1 -0
- package/static/browser/ldap-tree-viewer.esm.js +606 -0
- package/static/browser/ldap-tree-viewer.esm.js.map +1 -0
- package/static/browser/ldap-tree-viewer.js +614 -0
- package/static/browser/ldap-tree-viewer.js.map +1 -0
- package/static/browser/ldap-tree-viewer.min.js +2 -0
- package/static/browser/ldap-tree-viewer.min.js.map +1 -0
- package/static/browser/ldap-unit-editor/LdapUnitEditor.js +119 -0
- package/static/browser/ldap-unit-editor/LdapUnitEditor.js.map +1 -0
- package/static/browser/ldap-unit-editor/api/UnitApiClient.js +95 -0
- package/static/browser/ldap-unit-editor/api/UnitApiClient.js.map +1 -0
- package/static/browser/ldap-unit-editor/components/MoveUnitModal.js +295 -0
- package/static/browser/ldap-unit-editor/components/MoveUnitModal.js.map +1 -0
- package/static/browser/ldap-unit-editor/components/UnitPropertyEditor.js +321 -0
- package/static/browser/ldap-unit-editor/components/UnitPropertyEditor.js.map +1 -0
- package/static/browser/ldap-unit-editor/components/UnitTree.js +197 -0
- package/static/browser/ldap-unit-editor/components/UnitTree.js.map +1 -0
- package/static/browser/ldap-unit-editor/index.js +2 -0
- package/static/browser/ldap-unit-editor/index.js.map +1 -0
- package/static/browser/ldap-unit-editor/types.js +2 -0
- package/static/browser/ldap-unit-editor/types.js.map +1 -0
- package/static/browser/ldap-unit-editor.esm.js +1013 -0
- package/static/browser/ldap-unit-editor.esm.js.map +1 -0
- package/static/browser/ldap-unit-editor.js +1021 -0
- package/static/browser/ldap-unit-editor.js.map +1 -0
- package/static/browser/ldap-unit-editor.min.js +2 -0
- package/static/browser/ldap-unit-editor.min.js.map +1 -0
- package/static/browser/ldap-user-editor/LdapUserEditor.js +184 -0
- package/static/browser/ldap-user-editor/LdapUserEditor.js.map +1 -0
- package/static/browser/ldap-user-editor/api/UserApiClient.js +209 -0
- package/static/browser/ldap-user-editor/api/UserApiClient.js.map +1 -0
- package/static/browser/ldap-user-editor/cache/CacheManager.js +123 -0
- package/static/browser/ldap-user-editor/cache/CacheManager.js.map +1 -0
- package/static/browser/ldap-user-editor/components/MoveUserModal.js +302 -0
- package/static/browser/ldap-user-editor/components/MoveUserModal.js.map +1 -0
- package/static/browser/ldap-user-editor/components/PointerField.js +152 -0
- package/static/browser/ldap-user-editor/components/PointerField.js.map +1 -0
- package/static/browser/ldap-user-editor/components/UserEditor.js +608 -0
- package/static/browser/ldap-user-editor/components/UserEditor.js.map +1 -0
- package/static/browser/ldap-user-editor/components/UserList.js +181 -0
- package/static/browser/ldap-user-editor/components/UserList.js.map +1 -0
- package/static/browser/ldap-user-editor/components/UserTree.js +164 -0
- package/static/browser/ldap-user-editor/components/UserTree.js.map +1 -0
- package/static/browser/ldap-user-editor/index.js +2 -0
- package/static/browser/ldap-user-editor/index.js.map +1 -0
- package/static/browser/ldap-user-editor/types.js +2 -0
- package/static/browser/ldap-user-editor/types.js.map +1 -0
- package/static/browser/ldap-user-editor.css +2 -0
- package/static/browser/ldap-user-editor.css.map +1 -0
- package/static/browser/ldap-user-editor.esm.js +1897 -0
- package/static/browser/ldap-user-editor.esm.js.map +1 -0
- package/static/browser/ldap-user-editor.js +1905 -0
- package/static/browser/ldap-user-editor.js.map +1 -0
- package/static/browser/ldap-user-editor.min.js +2 -0
- package/static/browser/ldap-user-editor.min.js.map +1 -0
- package/static/browser/shared/components/Modal.js +121 -0
- package/static/browser/shared/components/Modal.js.map +1 -0
- package/static/browser/shared/components/StatusMessage.js +119 -0
- package/static/browser/shared/components/StatusMessage.js.map +1 -0
- package/static/browser/shared/index.js +7 -0
- package/static/browser/shared/index.js.map +1 -0
- package/static/browser/shared/types/index.js +37 -0
- package/static/browser/shared/types/index.js.map +1 -0
- package/static/browser/shared/utils/dom.js +78 -0
- package/static/browser/shared/utils/dom.js.map +1 -0
- package/static/browser/shared/utils/form.js +234 -0
- package/static/browser/shared/utils/form.js.map +1 -0
- package/static/browser/shared/utils/schema.js +121 -0
- package/static/browser/shared/utils/schema.js.map +1 -0
- package/static/browser/shared.esm.js +694 -0
- package/static/browser/shared.esm.js.map +1 -0
- package/static/browser/shared.js +723 -0
- package/static/browser/shared.js.map +1 -0
- package/static/browser/shared.min.js +2 -0
- package/static/browser/shared.min.js.map +1 -0
- package/static/schemas/ad/computers.json +92 -0
- package/static/schemas/ad/groups.json +55 -0
- package/static/schemas/ad/organizations.json +66 -0
- package/static/schemas/ad/users.json +116 -0
- package/static/schemas/standard/devices.json +72 -0
- package/static/schemas/standard/groups.json +54 -0
- package/static/schemas/standard/organizations.json +49 -0
- package/static/schemas/standard/users.json +86 -0
- package/static/schemas/twake/groups.json +75 -0
- package/static/schemas/twake/nomenclature/twakeAccountStatus.json +31 -0
- package/static/schemas/twake/nomenclature/twakeDeliveryMode.json +31 -0
- package/static/schemas/twake/nomenclature/twakeListType.json +31 -0
- package/static/schemas/twake/nomenclature/twakeMailboxType.json +31 -0
- package/static/schemas/twake/nomenclature/twakeTitle.json +31 -0
- package/static/schemas/twake/organizations.json +52 -0
- package/static/schemas/twake/positions.json +32 -0
- package/static/schemas/twake/users.json +112 -0
package/docs/static.md
ADDED
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
# Static Files Plugin
|
|
2
|
+
|
|
3
|
+
Serve static files and JSON schemas with dynamic configuration replacement.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The `static` plugin serves static files (HTML, CSS, JS, JSON, images) from a directory and provides special handling for JSON schema files with automatic configuration placeholder replacement.
|
|
8
|
+
|
|
9
|
+
## Configuration
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
--plugin core/static \
|
|
13
|
+
--static-path ./static \
|
|
14
|
+
--static-prefix /static
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**Environment Variables:**
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
DM_STATIC_PATH="./static"
|
|
21
|
+
DM_STATIC_PREFIX="/static"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Parameters
|
|
25
|
+
|
|
26
|
+
- `--static-path`: Directory containing static files (required)
|
|
27
|
+
- `--static-prefix`: URL prefix for serving files (default: `/static`)
|
|
28
|
+
|
|
29
|
+
## How It Works
|
|
30
|
+
|
|
31
|
+
### Regular Files
|
|
32
|
+
|
|
33
|
+
Serves files directly from the configured directory:
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
GET /static/index.html → ./static/index.html
|
|
37
|
+
GET /static/css/app.css → ./static/css/app.css
|
|
38
|
+
GET /static/js/main.js → ./static/js/main.js
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Schema Files
|
|
42
|
+
|
|
43
|
+
For JSON files in the `schemas/` subdirectory, performs on-the-fly placeholder replacement:
|
|
44
|
+
|
|
45
|
+
**Schema file (`./static/schemas/users.json`):**
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"entity": {
|
|
50
|
+
"base": "ou=users,__LDAP_BASE__"
|
|
51
|
+
},
|
|
52
|
+
"attributes": {
|
|
53
|
+
"twakeAccountStatus": {
|
|
54
|
+
"type": "pointer",
|
|
55
|
+
"branch": ["ou=twakeAccountStatus,ou=nomenclature,__LDAP_BASE__"]
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Request:**
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
GET /static/schemas/users.json
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Response (with `--ldap-base "dc=example,dc=com"`):**
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"entity": {
|
|
72
|
+
"base": "ou=users,dc=example,dc=com"
|
|
73
|
+
},
|
|
74
|
+
"attributes": {
|
|
75
|
+
"twakeAccountStatus": {
|
|
76
|
+
"type": "pointer",
|
|
77
|
+
"branch": ["ou=twakeAccountStatus,ou=nomenclature,dc=example,dc=com"]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Placeholder Replacement
|
|
84
|
+
|
|
85
|
+
### Format
|
|
86
|
+
|
|
87
|
+
Placeholders use double underscores and uppercase:
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
__CONFIG_KEY__
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Replacement Rules
|
|
94
|
+
|
|
95
|
+
Configuration keys are transformed:
|
|
96
|
+
|
|
97
|
+
- CLI: `--ldap-base` → Placeholder: `__LDAP_BASE__`
|
|
98
|
+
- CLI: `--ldap-top-organization` → Placeholder: `__LDAP_TOP_ORGANIZATION__`
|
|
99
|
+
- Env: `DM_LDAP_BASE` → Placeholder: `__LDAP_BASE__`
|
|
100
|
+
|
|
101
|
+
### Common Placeholders
|
|
102
|
+
|
|
103
|
+
| Placeholder | CLI Argument | Example Value |
|
|
104
|
+
| --------------------------- | ------------------------- | ----------------------------------- |
|
|
105
|
+
| `__LDAP_BASE__` | `--ldap-base` | `dc=example,dc=com` |
|
|
106
|
+
| `__LDAP_TOP_ORGANIZATION__` | `--ldap-top-organization` | `ou=organization,dc=example,dc=com` |
|
|
107
|
+
| `__API_PREFIX__` | `--api-prefix` | `/api` |
|
|
108
|
+
| `__STATIC_PREFIX__` | `--static-prefix` | `/static` |
|
|
109
|
+
|
|
110
|
+
## Use Cases
|
|
111
|
+
|
|
112
|
+
### 1. Schema Sharing
|
|
113
|
+
|
|
114
|
+
Share schemas between server and client-side JavaScript:
|
|
115
|
+
|
|
116
|
+
**Server-side:**
|
|
117
|
+
|
|
118
|
+
```javascript
|
|
119
|
+
// Schemas loaded with resolved placeholders
|
|
120
|
+
const schema = require('./schemas/users.json');
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Client-side:**
|
|
124
|
+
|
|
125
|
+
```javascript
|
|
126
|
+
// Fetch schema with resolved placeholders
|
|
127
|
+
const response = await fetch('/static/schemas/users.json');
|
|
128
|
+
const schema = await response.json();
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Both get the same schema with configuration values resolved.
|
|
132
|
+
|
|
133
|
+
### 2. Web Interface
|
|
134
|
+
|
|
135
|
+
Serve web-based LDAP management interface:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
--plugin core/static \
|
|
139
|
+
--static-path ./static \
|
|
140
|
+
--static-prefix /
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Files:
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
./static/
|
|
147
|
+
index.html → http://localhost:8081/
|
|
148
|
+
css/app.css → http://localhost:8081/css/app.css
|
|
149
|
+
js/ldap-tree.js → http://localhost:8081/js/ldap-tree.js
|
|
150
|
+
schemas/users.json → http://localhost:8081/schemas/users.json
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### 3. API Documentation
|
|
154
|
+
|
|
155
|
+
Serve OpenAPI/Swagger documentation:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
--plugin core/static \
|
|
159
|
+
--static-path ./api-docs \
|
|
160
|
+
--static-prefix /docs
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
GET /docs/openapi.json → ./api-docs/openapi.json
|
|
165
|
+
GET /docs/swagger-ui/ → ./api-docs/swagger-ui/index.html
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Examples
|
|
169
|
+
|
|
170
|
+
### Example 1: Basic Static Files
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
--plugin core/static \
|
|
174
|
+
--static-path ./public \
|
|
175
|
+
--static-prefix /static
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
**Directory structure:**
|
|
179
|
+
|
|
180
|
+
```
|
|
181
|
+
./public/
|
|
182
|
+
index.html
|
|
183
|
+
favicon.ico
|
|
184
|
+
css/
|
|
185
|
+
style.css
|
|
186
|
+
js/
|
|
187
|
+
app.js
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
**URLs:**
|
|
191
|
+
|
|
192
|
+
```
|
|
193
|
+
http://localhost:8081/static/index.html
|
|
194
|
+
http://localhost:8081/static/favicon.ico
|
|
195
|
+
http://localhost:8081/static/css/style.css
|
|
196
|
+
http://localhost:8081/static/js/app.js
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Example 2: Root Path Serving
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
--plugin core/static \
|
|
203
|
+
--static-path ./web \
|
|
204
|
+
--static-prefix /
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Serves files from root:
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
http://localhost:8081/index.html
|
|
211
|
+
http://localhost:8081/about.html
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Example 3: Schema Deployment
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
--plugin core/static \
|
|
218
|
+
--static-path ./static \
|
|
219
|
+
--static-prefix /static \
|
|
220
|
+
--ldap-base "dc=example,dc=com"
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Schema file (`./static/schemas/config.json`):**
|
|
224
|
+
|
|
225
|
+
```json
|
|
226
|
+
{
|
|
227
|
+
"ldapBase": "__LDAP_BASE__",
|
|
228
|
+
"apiEndpoint": "__API_PREFIX__/v1/ldap"
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
**Served as:**
|
|
233
|
+
|
|
234
|
+
```json
|
|
235
|
+
{
|
|
236
|
+
"ldapBase": "dc=example,dc=com",
|
|
237
|
+
"apiEndpoint": "/api/v1/ldap"
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Example 4: Multiple Static Plugins
|
|
242
|
+
|
|
243
|
+
Not directly supported, but you can nest directories:
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
--plugin core/static \
|
|
247
|
+
--static-path ./static
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
./static/
|
|
252
|
+
docs/
|
|
253
|
+
index.html
|
|
254
|
+
app/
|
|
255
|
+
index.html
|
|
256
|
+
schemas/
|
|
257
|
+
users.json
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Access via:
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
/static/docs/index.html
|
|
264
|
+
/static/app/index.html
|
|
265
|
+
/static/schemas/users.json
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## Security Considerations
|
|
269
|
+
|
|
270
|
+
### Path Traversal
|
|
271
|
+
|
|
272
|
+
The plugin uses Express's `express.static()` which prevents path traversal attacks:
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
# These are blocked:
|
|
276
|
+
GET /static/../../../etc/passwd
|
|
277
|
+
GET /static/%2e%2e%2f%2e%2e%2fetc/passwd
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Sensitive Files
|
|
281
|
+
|
|
282
|
+
**Do not serve** sensitive files:
|
|
283
|
+
|
|
284
|
+
- Configuration files with secrets
|
|
285
|
+
- Private keys
|
|
286
|
+
- Database files
|
|
287
|
+
- .env files
|
|
288
|
+
|
|
289
|
+
Use a dedicated static directory with only public files.
|
|
290
|
+
|
|
291
|
+
### Access Control
|
|
292
|
+
|
|
293
|
+
The static plugin has **no authentication**. All files are publicly accessible.
|
|
294
|
+
|
|
295
|
+
For restricted access:
|
|
296
|
+
|
|
297
|
+
1. Use authentication plugins
|
|
298
|
+
2. Implement custom middleware
|
|
299
|
+
3. Use reverse proxy with access controls
|
|
300
|
+
|
|
301
|
+
## MIME Types
|
|
302
|
+
|
|
303
|
+
Express automatically sets Content-Type based on file extension:
|
|
304
|
+
|
|
305
|
+
| Extension | Content-Type |
|
|
306
|
+
| --------- | ------------------------ |
|
|
307
|
+
| `.html` | `text/html` |
|
|
308
|
+
| `.css` | `text/css` |
|
|
309
|
+
| `.js` | `application/javascript` |
|
|
310
|
+
| `.json` | `application/json` |
|
|
311
|
+
| `.png` | `image/png` |
|
|
312
|
+
| `.jpg` | `image/jpeg` |
|
|
313
|
+
| `.svg` | `image/svg+xml` |
|
|
314
|
+
|
|
315
|
+
## Caching
|
|
316
|
+
|
|
317
|
+
Express `static` middleware supports HTTP caching headers:
|
|
318
|
+
|
|
319
|
+
```bash
|
|
320
|
+
# Browser caches for 1 day
|
|
321
|
+
Cache-Control: public, max-age=86400
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
For production, consider using a CDN or reverse proxy with caching.
|
|
325
|
+
|
|
326
|
+
## Integration with ldap-tree-viewer
|
|
327
|
+
|
|
328
|
+
The LDAP tree viewer web interface uses the static plugin:
|
|
329
|
+
|
|
330
|
+
```bash
|
|
331
|
+
--plugin core/static \
|
|
332
|
+
--plugin core/ldap/organization \
|
|
333
|
+
--static-path ./static \
|
|
334
|
+
--ldap-organization-max-subnodes 50
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
Files:
|
|
338
|
+
|
|
339
|
+
```
|
|
340
|
+
./static/
|
|
341
|
+
ldap-tree-viewer.html # Web interface
|
|
342
|
+
schemas/ # JSON schemas with placeholders
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
The viewer fetches schemas with resolved LDAP configuration:
|
|
346
|
+
|
|
347
|
+
```javascript
|
|
348
|
+
const response = await fetch('/static/schemas/organizations.json');
|
|
349
|
+
const schema = await response.json();
|
|
350
|
+
// schema.entity.base = "ou=organization,dc=example,dc=com" (resolved)
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
## Troubleshooting
|
|
354
|
+
|
|
355
|
+
### Problem: 404 Not Found
|
|
356
|
+
|
|
357
|
+
**Symptoms:**
|
|
358
|
+
|
|
359
|
+
```
|
|
360
|
+
GET /static/index.html → 404
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
**Solutions:**
|
|
364
|
+
|
|
365
|
+
1. Verify file exists:
|
|
366
|
+
|
|
367
|
+
```bash
|
|
368
|
+
ls ./static/index.html
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
2. Check static path configuration:
|
|
372
|
+
|
|
373
|
+
```bash
|
|
374
|
+
--static-path ./static
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
3. Verify prefix matches URL:
|
|
378
|
+
```bash
|
|
379
|
+
--static-prefix /static
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
### Problem: Placeholders Not Replaced
|
|
383
|
+
|
|
384
|
+
**Symptoms:**
|
|
385
|
+
Schema still contains `__LDAP_BASE__` after fetching.
|
|
386
|
+
|
|
387
|
+
**Solutions:**
|
|
388
|
+
|
|
389
|
+
1. Ensure file is in `schemas/` subdirectory
|
|
390
|
+
2. Check file extension is `.json`
|
|
391
|
+
3. Verify config parameter is set:
|
|
392
|
+
```bash
|
|
393
|
+
--ldap-base "dc=example,dc=com"
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### Problem: CORS Errors
|
|
397
|
+
|
|
398
|
+
**Symptoms:**
|
|
399
|
+
Browser blocks requests from different origin.
|
|
400
|
+
|
|
401
|
+
**Solutions:**
|
|
402
|
+
|
|
403
|
+
1. Use reverse proxy to serve from same origin
|
|
404
|
+
2. Add CORS headers via custom middleware
|
|
405
|
+
3. Configure browser to allow CORS (development only)
|
|
406
|
+
|
|
407
|
+
## See Also
|
|
408
|
+
|
|
409
|
+
- [ldapOrganizations.md](ldapOrganizations.md) - LDAP tree viewer integration
|
|
410
|
+
- [ldapFlatGeneric.md](ldapFlatGeneric.md) - Schema-driven LDAP management
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Twake Calendar Resources Plugin
|
|
2
|
+
|
|
3
|
+
Plugin to automatically synchronize LDAP resources (meeting rooms, equipment, etc.) with Twake Calendar via its WebAdmin API.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Automatic Creation**: When a resource is added to the configured LDAP branch, it's automatically created in Twake Calendar
|
|
8
|
+
- **Automatic Updates**: When a resource is modified in LDAP, changes are synced to Twake Calendar
|
|
9
|
+
- **Automatic Deletion**: When a resource is removed from LDAP, it's deleted from Twake Calendar
|
|
10
|
+
- **Flexible Configuration**: Configure which LDAP branch and objectClass to monitor
|
|
11
|
+
|
|
12
|
+
## Configuration
|
|
13
|
+
|
|
14
|
+
### Environment Variables
|
|
15
|
+
|
|
16
|
+
- `DM_CALENDAR_WEBADMIN_URL`: URL of the Twake Calendar WebAdmin API (default: `http://localhost:8080`)
|
|
17
|
+
- `DM_CALENDAR_WEBADMIN_TOKEN`: Bearer token for WebAdmin API authentication
|
|
18
|
+
- `DM_CALENDAR_RESOURCE_BASE`: LDAP branch to monitor for resources (e.g., `ou=resources,dc=example,dc=com`)
|
|
19
|
+
- `DM_CALENDAR_RESOURCE_OBJECTCLASS`: Optional objectClass filter (only process entries with this objectClass)
|
|
20
|
+
- `DM_CALENDAR_RESOURCE_CREATOR`: Default creator email for resources (default: `admin@example.com`)
|
|
21
|
+
- `DM_CALENDAR_RESOURCE_DOMAIN`: Default domain for resources (extracted from DN if not specified)
|
|
22
|
+
|
|
23
|
+
### Required Dependencies
|
|
24
|
+
|
|
25
|
+
This plugin requires:
|
|
26
|
+
|
|
27
|
+
- `ldapFlat` plugin with a schema configured for calendar resources
|
|
28
|
+
- `onLdapChange` plugin to detect LDAP modifications
|
|
29
|
+
|
|
30
|
+
## LDAP Schema
|
|
31
|
+
|
|
32
|
+
The plugin works with any ldapFlat schema that has `entity.name` set to `calendarResource`. Example schema:
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"entity": {
|
|
37
|
+
"name": "calendarResource",
|
|
38
|
+
"mainAttribute": "cn",
|
|
39
|
+
"objectClass": ["top", "device"],
|
|
40
|
+
"singularName": "resource",
|
|
41
|
+
"pluralName": "resources",
|
|
42
|
+
"base": "ou=resources,__ldap_base__"
|
|
43
|
+
},
|
|
44
|
+
"attributes": {
|
|
45
|
+
"objectClass": {
|
|
46
|
+
"type": "array",
|
|
47
|
+
"default": ["top", "device"],
|
|
48
|
+
"required": true,
|
|
49
|
+
"fixed": true
|
|
50
|
+
},
|
|
51
|
+
"cn": {
|
|
52
|
+
"type": "string",
|
|
53
|
+
"required": true
|
|
54
|
+
},
|
|
55
|
+
"description": {
|
|
56
|
+
"type": "string"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Twake Calendar API
|
|
63
|
+
|
|
64
|
+
The plugin uses the following WebAdmin API endpoints:
|
|
65
|
+
|
|
66
|
+
- `POST /resources` - Create a new resource
|
|
67
|
+
- `PATCH /resources/{id}` - Update an existing resource
|
|
68
|
+
- `DELETE /resources/{id}` - Delete a resource
|
|
69
|
+
|
|
70
|
+
### Resource Data Format
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"id": "resource-id",
|
|
75
|
+
"name": "Resource Name",
|
|
76
|
+
"description": "Optional description",
|
|
77
|
+
"creator": "admin@example.com",
|
|
78
|
+
"domain": "example.com"
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Example Configuration
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Twake Calendar WebAdmin API
|
|
86
|
+
DM_CALENDAR_WEBADMIN_URL="https://calendar.example.com/webadmin"
|
|
87
|
+
DM_CALENDAR_WEBADMIN_TOKEN="your-api-token"
|
|
88
|
+
|
|
89
|
+
# LDAP Resources Configuration
|
|
90
|
+
DM_CALENDAR_RESOURCE_BASE="ou=resources,dc=example,dc=com"
|
|
91
|
+
DM_CALENDAR_RESOURCE_OBJECTCLASS="device"
|
|
92
|
+
DM_CALENDAR_RESOURCE_CREATOR="calendar-admin@example.com"
|
|
93
|
+
DM_CALENDAR_RESOURCE_DOMAIN="example.com"
|
|
94
|
+
|
|
95
|
+
# ldapFlat schema
|
|
96
|
+
DM_LDAP_FLAT_SCHEMA="/path/to/calendar-resources-schema.json"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Usage
|
|
100
|
+
|
|
101
|
+
1. Configure the environment variables
|
|
102
|
+
2. Create an ldapFlat schema for calendar resources (see example above)
|
|
103
|
+
3. Add the plugin to `DM_PLUGINS`:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
DM_PLUGINS="core/ldap/onChange,core/ldap/flatGeneric,twake/calendarResources"
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
4. Start ldap-rest - resources will be automatically synced
|
|
110
|
+
|
|
111
|
+
## Logging
|
|
112
|
+
|
|
113
|
+
The plugin logs all API calls with the following information:
|
|
114
|
+
|
|
115
|
+
- Success/failure status
|
|
116
|
+
- HTTP status code
|
|
117
|
+
- Resource DN
|
|
118
|
+
- Resource name/ID
|
|
119
|
+
|
|
120
|
+
Example log:
|
|
121
|
+
|
|
122
|
+
```json
|
|
123
|
+
{
|
|
124
|
+
"plugin": "calendarResources",
|
|
125
|
+
"event": "ldapcalendarResourceadddone",
|
|
126
|
+
"result": "success",
|
|
127
|
+
"http_status": 201,
|
|
128
|
+
"dn": "cn=Meeting Room 1,ou=resources,dc=example,dc=com",
|
|
129
|
+
"resourceName": "Meeting Room 1"
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Troubleshooting
|
|
134
|
+
|
|
135
|
+
### Resources not syncing
|
|
136
|
+
|
|
137
|
+
1. Check that `DM_CALENDAR_WEBADMIN_URL` is correctly configured and accessible
|
|
138
|
+
2. Verify that `DM_CALENDAR_WEBADMIN_TOKEN` is valid
|
|
139
|
+
3. Check logs for API errors
|
|
140
|
+
4. Ensure the ldapFlat schema has `entity.name` set to `calendarResource`
|
|
141
|
+
|
|
142
|
+
### Authentication errors
|
|
143
|
+
|
|
144
|
+
Ensure `DM_CALENDAR_WEBADMIN_TOKEN` is set and valid. The token is sent as a Bearer token in the Authorization header.
|
|
145
|
+
|
|
146
|
+
### Wrong resources being synced
|
|
147
|
+
|
|
148
|
+
Use `DM_CALENDAR_RESOURCE_BASE` and `DM_CALENDAR_RESOURCE_OBJECTCLASS` to filter which LDAP entries are considered resources.
|