@rocket.chat/houston 0.27.0-next.2 → 2.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.
- package/LICENSE +1 -1
- package/README.md +108 -15
- package/bin/houston +62 -0
- package/data/docs/ARCHITECTURE.md +387 -0
- package/data/docs/automation.md +107 -0
- package/data/docs/e2ee.md +76 -0
- package/data/docs/eks.md +258 -0
- package/data/docs/gui.md +282 -0
- package/data/docs/guide.md +669 -0
- package/data/docs/kubernetes.md +138 -0
- package/data/docs/troubleshooting.md +193 -0
- package/data/docs/upgrading.md +84 -0
- package/data/docs/voice.md +253 -0
- package/data/iam/engineer-policy.json +11 -0
- package/data/iam/engineer-rbac.yaml +42 -0
- package/data/iam/operator-policy.json +211 -0
- package/data/loadtest/badbot.js +22 -0
- package/data/loadtest/common.js +168 -0
- package/data/loadtest/custom.js +20 -0
- package/data/loadtest/journey.js +58 -0
- package/data/loadtest/login.js +18 -0
- package/data/loadtest/messages.js +13 -0
- package/data/loadtest/mixed.js +39 -0
- package/data/loadtest/read.js +12 -0
- package/data/loadtest/webhook.js +20 -0
- package/data/monitoring/houston-logs.json +98 -0
- package/data/monitoring/k6-loadtest.json +610 -0
- package/data/monitoring/mongodb-exporter.json +3007 -0
- package/data/monitoring/node-exporter-full.json +16114 -0
- package/data/monitoring/rocketchat-metrics.json +6471 -0
- package/data/presets/airgapped.yaml +16 -0
- package/data/presets/default.yaml +9 -0
- package/data/seed/avatar-0.png +0 -0
- package/data/seed/avatar-1.png +0 -0
- package/data/seed/avatar-2.png +0 -0
- package/data/seed/avatar-3.png +0 -0
- package/data/seed/avatar-4.png +0 -0
- package/data/seed/avatar-5.png +0 -0
- package/data/seed/avatar-6.png +0 -0
- package/data/seed/avatar-7.png +0 -0
- package/data/seed/seed-metrics.csv +3 -0
- package/data/seed/seed-preview.png +0 -0
- package/data/seed/seed-report.pdf +32 -0
- package/data/seed/seed-runbook.txt +3 -0
- package/data/skill/SKILL.md +399 -0
- package/data/versions.yaml +55 -0
- package/data/voice/freeswitch/drachtio.xml +52 -0
- package/data/voice/freeswitch/public.xml +87 -0
- package/data/webui/app.css +2003 -0
- package/data/webui/index.html +678 -0
- package/data/webui/js/api.js +561 -0
- package/data/webui/js/boot.js +44 -0
- package/data/webui/js/clusters-tail.js +1377 -0
- package/data/webui/js/clusters.js +896 -0
- package/data/webui/js/create.js +276 -0
- package/data/webui/js/detail.js +507 -0
- package/data/webui/js/jobs.js +636 -0
- package/data/webui/js/logs.js +634 -0
- package/data/webui/js/main.js +14 -0
- package/data/webui/js/options.js +408 -0
- package/data/webui/js/people.js +438 -0
- package/data/webui/js/perf.js +303 -0
- package/data/webui/js/render.js +438 -0
- package/data/webui/js/shared.js +3 -0
- package/data/webui/js/state.js +583 -0
- package/data/webui/js/theme.js +123 -0
- package/data/webui/js/util.js +584 -0
- package/dist/cli/app.js +593 -0
- package/dist/cli/capabilities.js +76 -0
- package/dist/cli/cell-widths.js +495 -0
- package/dist/cli/entry.js +10 -0
- package/dist/cli/error-panel.js +492 -0
- package/dist/cli/handlers/actor.js +84 -0
- package/dist/cli/handlers/https.js +614 -0
- package/dist/cli/handlers/prompt.js +299 -0
- package/dist/cli/handlers/users.js +226 -0
- package/dist/cli/handlers.js +3678 -0
- package/dist/cli/help.js +183 -0
- package/dist/cli/index.js +15 -0
- package/dist/cli/perf.js +810 -0
- package/dist/cli/render.js +254 -0
- package/dist/cli/serve.js +858 -0
- package/dist/cli/spec-data.js +2593 -0
- package/dist/cli/spec-types.js +8 -0
- package/dist/cli/usage-error.js +520 -0
- package/dist/cli/wire.js +70 -0
- package/dist/core/audit.js +346 -0
- package/dist/core/backup-compat.js +85 -0
- package/dist/core/backup.js +1639 -0
- package/dist/core/cluster.js +1398 -0
- package/dist/core/configimport.js +344 -0
- package/dist/core/data.js +267 -0
- package/dist/core/database-of.js +82 -0
- package/dist/core/diagnose.js +159 -0
- package/dist/core/doctor.js +1518 -0
- package/dist/core/edge/acme.js +338 -0
- package/dist/core/edge/engine.js +500 -0
- package/dist/core/edge/networks.js +174 -0
- package/dist/core/edge/paths.js +107 -0
- package/dist/core/edge/routes.js +251 -0
- package/dist/core/edge/routeyml.js +195 -0
- package/dist/core/edge/runtime.js +493 -0
- package/dist/core/edge/spec.js +305 -0
- package/dist/core/edge/types.js +202 -0
- package/dist/core/eks-docs.js +135 -0
- package/dist/core/eks.js +2240 -0
- package/dist/core/envvars.js +562 -0
- package/dist/core/eventlog.js +541 -0
- package/dist/core/firstrun.js +153 -0
- package/dist/core/journal.js +691 -0
- package/dist/core/kube/ask.js +231 -0
- package/dist/core/kube/capabilities.js +269 -0
- package/dist/core/kube/certmanager.js +452 -0
- package/dist/core/kube/chart.js +413 -0
- package/dist/core/kube/cluster.js +196 -0
- package/dist/core/kube/context.js +545 -0
- package/dist/core/kube/endpoints.js +448 -0
- package/dist/core/kube/exec.js +195 -0
- package/dist/core/kube/forward.js +732 -0
- package/dist/core/kube/grafana-ingress.js +110 -0
- package/dist/core/kube/ingress.js +218 -0
- package/dist/core/kube/manifests.js +361 -0
- package/dist/core/kube/monitoring.js +768 -0
- package/dist/core/kube/names.js +237 -0
- package/dist/core/kube/namespace.js +678 -0
- package/dist/core/kube/operator.js +941 -0
- package/dist/core/kube/probe.js +202 -0
- package/dist/core/kube/reachability.js +163 -0
- package/dist/core/kube/release.js +439 -0
- package/dist/core/kube/replicaset.js +180 -0
- package/dist/core/kube/scale.js +398 -0
- package/dist/core/kube/status.js +633 -0
- package/dist/core/kube/tools.js +238 -0
- package/dist/core/kube/transfer.js +173 -0
- package/dist/core/kube/workspace.js +423 -0
- package/dist/core/lifecycle/admin.js +64 -0
- package/dist/core/lifecycle/create-docker.js +1533 -0
- package/dist/core/lifecycle/create-k8s.js +939 -0
- package/dist/core/lifecycle/destroy.js +339 -0
- package/dist/core/lifecycle/inspect.js +635 -0
- package/dist/core/lifecycle/naming.js +298 -0
- package/dist/core/lifecycle/notes.js +726 -0
- package/dist/core/lifecycle/ownership.js +313 -0
- package/dist/core/lifecycle/payload.js +401 -0
- package/dist/core/lifecycle/ports.js +388 -0
- package/dist/core/lifecycle/preconditions.js +367 -0
- package/dist/core/lifecycle/pruning.js +551 -0
- package/dist/core/lifecycle/ready.js +753 -0
- package/dist/core/lifecycle/request.js +525 -0
- package/dist/core/lifecycle/seeding.js +281 -0
- package/dist/core/lifecycle/sizing.js +392 -0
- package/dist/core/lifecycle/state.js +286 -0
- package/dist/core/lifecycle/tlsplan.js +704 -0
- package/dist/core/lifecycle/types.js +232 -0
- package/dist/core/loadtest.js +995 -0
- package/dist/core/migrate.js +612 -0
- package/dist/core/monitor.js +494 -0
- package/dist/core/postready.js +969 -0
- package/dist/core/promote.js +804 -0
- package/dist/core/rcapi.js +1285 -0
- package/dist/core/recovery.js +75 -0
- package/dist/core/runner/engine.js +394 -0
- package/dist/core/runner/host.js +298 -0
- package/dist/core/runner/locks.js +129 -0
- package/dist/core/runner/paths.js +173 -0
- package/dist/core/runner/ports.js +172 -0
- package/dist/core/runner/queries.js +612 -0
- package/dist/core/runner/record.js +563 -0
- package/dist/core/scaleseed.js +271 -0
- package/dist/core/seed-db.js +208 -0
- package/dist/core/sessions.js +472 -0
- package/dist/core/skill.js +326 -0
- package/dist/core/sso-identities.js +172 -0
- package/dist/core/sso.js +703 -0
- package/dist/core/tls-local.js +311 -0
- package/dist/core/tls.js +878 -0
- package/dist/core/topology.js +482 -0
- package/dist/core/upgrade.js +868 -0
- package/dist/core/users.js +739 -0
- package/dist/lib/audit.js +100 -0
- package/dist/lib/close-matches.js +238 -0
- package/dist/lib/compose.js +672 -0
- package/dist/lib/config.js +1398 -0
- package/dist/lib/context.js +18 -0
- package/dist/lib/errors.js +305 -0
- package/dist/lib/events.js +208 -0
- package/dist/lib/float-text.js +126 -0
- package/dist/lib/format.js +1320 -0
- package/dist/lib/home.js +325 -0
- package/dist/lib/journal.js +122 -0
- package/dist/lib/json-text.js +733 -0
- package/dist/lib/jsonout.js +382 -0
- package/dist/lib/lock.js +516 -0
- package/dist/lib/login-name.js +202 -0
- package/dist/lib/map-limit.js +29 -0
- package/dist/lib/mkdir-parents.js +90 -0
- package/dist/lib/mongo-kernel.js +67 -0
- package/dist/lib/monitoring.js +492 -0
- package/dist/lib/platform-name.js +59 -0
- package/dist/lib/presets/common.js +390 -0
- package/dist/lib/presets/composite.js +326 -0
- package/dist/lib/presets/e2ee.js +143 -0
- package/dist/lib/presets/email.js +172 -0
- package/dist/lib/presets/guides.js +27 -0
- package/dist/lib/presets/index.js +490 -0
- package/dist/lib/presets/keycloak.js +369 -0
- package/dist/lib/presets/ldap.js +1285 -0
- package/dist/lib/presets/livechat.js +220 -0
- package/dist/lib/presets/multi-instance.js +124 -0
- package/dist/lib/presets/oidc.js +161 -0
- package/dist/lib/presets/public.js +496 -0
- package/dist/lib/presets/registry.js +64 -0
- package/dist/lib/presets/s3-minio.js +300 -0
- package/dist/lib/presets/saml.js +149 -0
- package/dist/lib/presets/scenario.js +51 -0
- package/dist/lib/presets/types.js +86 -0
- package/dist/lib/presets/voice-pbx.js +320 -0
- package/dist/lib/presets/voice.js +345 -0
- package/dist/lib/presets/webhooks.js +182 -0
- package/dist/lib/redact.js +106 -0
- package/dist/lib/seed-options.js +68 -0
- package/dist/lib/seed-profiles.js +59 -0
- package/dist/lib/targz.js +1383 -0
- package/dist/lib/teammode.js +25 -0
- package/dist/lib/tempdir.js +162 -0
- package/dist/lib/unicode-tables.js +2335 -0
- package/dist/lib/version-spec.js +357 -0
- package/dist/lib/versions.js +463 -0
- package/dist/lib/yaml-dump.js +1361 -0
- package/dist/perf/baseline.js +168 -0
- package/dist/perf/constrain.js +296 -0
- package/dist/perf/k6.js +235 -0
- package/dist/perf/mongoprof.js +171 -0
- package/dist/perf/rcmetrics.js +178 -0
- package/dist/perf/report.js +386 -0
- package/dist/perf/resources.js +224 -0
- package/dist/perf/slo.js +111 -0
- package/dist/perf/timeline.js +187 -0
- package/dist/perf/timings.js +85 -0
- package/dist/perf/verdict.js +201 -0
- package/dist/seams/aws-cli.js +126 -0
- package/dist/seams/docker-cli.js +280 -0
- package/dist/seams/exec.js +861 -0
- package/dist/seams/fs/lock.js +528 -0
- package/dist/seams/kubectl.js +83 -0
- package/dist/seams/rc-http.js +921 -0
- package/dist/seed/apply.js +190 -0
- package/dist/seed/assets.js +76 -0
- package/dist/seed/check.js +391 -0
- package/dist/seed/client.js +172 -0
- package/dist/seed/executor.js +726 -0
- package/dist/seed/history.js +281 -0
- package/dist/seed/kinds.js +91 -0
- package/dist/seed/plan.js +432 -0
- package/dist/seed/receipt.js +339 -0
- package/dist/seed/repairs.js +75 -0
- package/dist/seed/verification.js +363 -0
- package/dist/seed/wording.js +248 -0
- package/dist/web/app.js +326 -0
- package/dist/web/jobs.js +510 -0
- package/dist/web/route-deps.js +211 -0
- package/dist/web/route-table.js +213 -0
- package/dist/web/routes/backup.js +244 -0
- package/dist/web/routes/clusters.js +303 -0
- package/dist/web/routes/data.js +187 -0
- package/dist/web/routes/edge.js +82 -0
- package/dist/web/routes/index.js +63 -0
- package/dist/web/routes/jobs.js +95 -0
- package/dist/web/routes/logs.js +297 -0
- package/dist/web/routes/meta.js +191 -0
- package/dist/web/routes/people.js +151 -0
- package/dist/web/routes/perf.js +95 -0
- package/dist/web/routes/repros.js +550 -0
- package/dist/web/routes/session.js +361 -0
- package/dist/web/routes/spa.js +198 -0
- package/dist/web/security.js +475 -0
- package/dist/web/signin.js +246 -0
- package/package.json +67 -32
- package/.eslintrc +0 -94
- package/.swcrc +0 -18
- package/dist/bin.js +0 -3
- package/dist/cli.js +0 -184
- package/dist/commands/createBranch.js +0 -192
- package/src/bin.js +0 -4
- package/src/cli.ts +0 -25
- package/src/commands/createBranch.ts +0 -25
- package/src-old/logs.js +0 -323
- package/src-old/md.js +0 -191
- package/src-old/release-table.js +0 -60
- package/src-old/set-version.js +0 -614
- package/src-old/utils.js +0 -15
|
@@ -0,0 +1,1285 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.AD_SEED = exports.GENERATOR = exports.SHIPPED_USERS_MAX = exports.UI_PORT_LABEL = exports.UI_CONTAINER_PORT = void 0;
|
|
37
|
+
exports.directoryHost = directoryHost;
|
|
38
|
+
exports.withCertificate = withCertificate;
|
|
39
|
+
exports.scenario = scenario;
|
|
40
|
+
exports.build = build;
|
|
41
|
+
/**
|
|
42
|
+
* Dynamic `ldap` preset: an OpenLDAP directory seeded with N users + a group, with
|
|
43
|
+
* Rocket.Chat wired to authenticate against it.
|
|
44
|
+
*
|
|
45
|
+
* The only preset that is a SCENARIO -- one deployment-neutral intent with a Compose adapter
|
|
46
|
+
* and a Kubernetes adapter, rather than one Preset carrying both renderings the way `saml`
|
|
47
|
+
* and `oidc` do.
|
|
48
|
+
*
|
|
49
|
+
* Parameters (via `--set`):
|
|
50
|
+
* users number of LDAP users to generate (default 5). Set high (e.g. 130000) to
|
|
51
|
+
* reproduce LDAP-sync scale/performance issues.
|
|
52
|
+
* domain LDAP domain (default example.com) -> base DN dc=example,dc=com.
|
|
53
|
+
* directory 'ad' serves the users from Samba as Active Directory instead (`AD_SEED`).
|
|
54
|
+
* idp 'saml' or 'oidc' adds a Keycloak that federates this directory (`federation`),
|
|
55
|
+
* so the same users also sign in by SSO; `mfa=on` makes it ask for TOTP.
|
|
56
|
+
*
|
|
57
|
+
* Every user `userN` has password `userN`, so you can log in immediately as `user1` /
|
|
58
|
+
* `user1`. The local admin (admin/admin123) still works via LDAP_Login_Fallback, so
|
|
59
|
+
* houston's own API/token calls keep functioning.
|
|
60
|
+
*/
|
|
61
|
+
const node_crypto_1 = require("node:crypto");
|
|
62
|
+
const common_1 = require("./common");
|
|
63
|
+
const guides_1 = require("./guides");
|
|
64
|
+
const keycloak = __importStar(require("./keycloak"));
|
|
65
|
+
const registry_1 = require("./registry");
|
|
66
|
+
const scenario_1 = require("./scenario");
|
|
67
|
+
const types_1 = require("./types");
|
|
68
|
+
/**
|
|
69
|
+
* phpLDAPadmin's host port in this workspace (`ports` over the ONE registry both runtimes
|
|
70
|
+
* read). Compose publishes it directly; Kubernetes declares it on the Service (see
|
|
71
|
+
* `UI_PORT_LABEL`) and the lifecycle forwards it. Same number either way, so a ticket's
|
|
72
|
+
* instructions do not depend on where the workspace happens to run.
|
|
73
|
+
*/
|
|
74
|
+
function uiPortOf(ports) {
|
|
75
|
+
return (0, common_1.presetPort)('ldap', 0, ports);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* phpLDAPadmin 2, the maintained line (amd64/arm64). osixia/phpldapadmin:0.9.0 shipped 1.2.5
|
|
79
|
+
* on a PHP nobody patches any more; 2.3.12 is the security release built on PHP 8.4.27.
|
|
80
|
+
*/
|
|
81
|
+
const UI_IMAGE = 'phpldapadmin/phpldapadmin:2.3.12';
|
|
82
|
+
/** What it listens on inside: it runs as www-data, so not 80. */
|
|
83
|
+
exports.UI_CONTAINER_PORT = 8080;
|
|
84
|
+
/**
|
|
85
|
+
* A Service wearing this label is published on the host port it names. One convention for
|
|
86
|
+
* every scenario, so the four presets still to be adapted need no new mechanism -- and no
|
|
87
|
+
* second place to declare a port that could disagree with `config.PRESET_PORTS`.
|
|
88
|
+
*/
|
|
89
|
+
exports.UI_PORT_LABEL = 'houston.io/ui-port';
|
|
90
|
+
/**
|
|
91
|
+
* OpenLDAP 2.6 LTS (Symas packages, Debian 13), amd64/arm64: a maintained drop-in for
|
|
92
|
+
* osixia/openldap:1.5.0, whose OpenLDAP 2.4.57 and Debian 10 are both past end of life. The
|
|
93
|
+
* same environment drives it, read-only user included. Pinned by digest: one small publisher,
|
|
94
|
+
* and a moved tag would change the directory under a ticket.
|
|
95
|
+
*/
|
|
96
|
+
const DIRECTORY_IMAGE = 'ghcr.io/intechcore/openldap:2.6.16-1@sha256:04a95ae6131d8f21ee15b025c2dc7318c2922c9249fa469c7a780cceddba06f1';
|
|
97
|
+
/** The image applies every LDIF here on first boot (`ldapadd -c`: existing entries skipped). */
|
|
98
|
+
const BOOTSTRAP_PATH = '/bootstrap/50-rc-users.ldif';
|
|
99
|
+
const GROUP_CN = 'rc-users';
|
|
100
|
+
const GID = '5000';
|
|
101
|
+
const PARAMS_HELP = Object.freeze({
|
|
102
|
+
users: 'number of LDAP users to generate (default 5; try 130000 for scale)',
|
|
103
|
+
domain: 'LDAP domain (default example.com)',
|
|
104
|
+
groups: "'on' adds groups rocket-chat (every user but the last), rocket-admin (user1) and " +
|
|
105
|
+
'employee (everyone), and lets only rocket-chat log in (default off)',
|
|
106
|
+
bind: "'service' binds Rocket.Chat as a read-only directory user, whom slapd limits to 500 " +
|
|
107
|
+
"entries per search, as many real directories do (default 'admin', unlimited)",
|
|
108
|
+
tls: "'ldaps' (port 636) or 'starttls' (389), with a certificate from houston's own CA " +
|
|
109
|
+
'(default none)',
|
|
110
|
+
trust: "'none' leaves houston's CA out of Rocket.Chat, to reproduce a certificate error " +
|
|
111
|
+
"(default 'houston')",
|
|
112
|
+
directory: "'ad' serves the same users from Samba as Active Directory: sAMAccountName, " +
|
|
113
|
+
"objectGUID, nested groups (default 'openldap')",
|
|
114
|
+
idp: "'saml' or 'oidc' puts Keycloak in front of this directory, so the same users also " +
|
|
115
|
+
'sign in by SSO (default none)',
|
|
116
|
+
mfa: "'on' has Keycloak ask for a one-time code at SSO sign-in; needs idp (default off)",
|
|
117
|
+
idp_host: 'with idp: hostname your browser reaches Keycloak on (default as the saml and oidc ' +
|
|
118
|
+
'presets: localhost, or keycloak for oidc)',
|
|
119
|
+
});
|
|
120
|
+
/** Where the image reads its TLS files, in place, by the names `slapdEnv` gives them. */
|
|
121
|
+
const CERTS_DIR = '/container/certs';
|
|
122
|
+
const CERT_FILES = ['ldap.crt', 'ldap.key', 'ca.crt'];
|
|
123
|
+
/** The Kubernetes Secret `withCertificate` adds and the Deployment mounts. */
|
|
124
|
+
const TLS_SECRET = 'openldap-tls';
|
|
125
|
+
/** The groups `--set groups=on` adds, beside `rc-users`; each with its gidNumber. */
|
|
126
|
+
const LAB_GROUPS = [
|
|
127
|
+
['rocket-chat', '5001'],
|
|
128
|
+
['rocket-admin', '5002'],
|
|
129
|
+
['employee', '5003'],
|
|
130
|
+
];
|
|
131
|
+
/**
|
|
132
|
+
* Past this many users the LDIF is generated inside the container rather than shipped: a
|
|
133
|
+
* thousand users is 272 KB, past the 256 KiB a ConfigMap applied client-side can carry, and
|
|
134
|
+
* 130,000 is 37.7 MB. Below it nothing changes, so every existing workspace builds as before.
|
|
135
|
+
*/
|
|
136
|
+
exports.SHIPPED_USERS_MAX = 500;
|
|
137
|
+
/** The generator, an sh + awk transcription of `ldif()`; a spec holds the two byte-equal. */
|
|
138
|
+
exports.GENERATOR = String.raw `#!/bin/sh
|
|
139
|
+
# The directory houston would ship as LDIF, generated here instead: past a few hundred users
|
|
140
|
+
# the file outgrows a Kubernetes ConfigMap. Byte for byte the LDIF houston writes for the
|
|
141
|
+
# same parameters, users first, then rc-users, then the lab groups when asked for.
|
|
142
|
+
set -eu
|
|
143
|
+
awk -v n="$HOUSTON_LDAP_USERS" -v base="$HOUSTON_LDAP_BASE_DN" -v domain="$HOUSTON_LDAP_DOMAIN" \
|
|
144
|
+
-v groups="$HOUSTON_LDAP_GROUPS" -v admin="$LDAP_ADMIN_PASSWORD" '
|
|
145
|
+
function group(cn, gid, first, last, i) {
|
|
146
|
+
printf "\ndn: cn=%s,ou=groups,%s\nobjectClass: top\nobjectClass: posixGroup\ncn: %s\ngidNumber: %s\n", cn, base, cn, gid
|
|
147
|
+
for (i = first; i <= last; i++) printf "memberUid: user%d\n", i
|
|
148
|
+
}
|
|
149
|
+
BEGIN {
|
|
150
|
+
printf "dn: cn=admin,%s\nobjectClass: simpleSecurityObject\nobjectClass: organizationalRole\ncn: admin\nuserPassword: %s\n\n", base, admin
|
|
151
|
+
printf "dn: ou=people,%s\nchangetype: delete\n\n", base
|
|
152
|
+
printf "dn: ou=Users,%s\nobjectClass: organizationalUnit\nou: Users\n\n", base
|
|
153
|
+
printf "dn: ou=groups,%s\nobjectClass: organizationalUnit\nou: groups\n\n", base
|
|
154
|
+
for (i = 1; i <= n; i++) {
|
|
155
|
+
printf "dn: uid=user%d,ou=Users,%s\nobjectClass: inetOrgPerson\nobjectClass: posixAccount\n", i, base
|
|
156
|
+
printf "cn: User %d\nsn: %d\nuid: user%d\nuidNumber: %d\ngidNumber: 5000\n", i, i, i, 1000 + i
|
|
157
|
+
printf "homeDirectory: /home/user%d\nmail: user%d@%s\nuserPassword: user%d\n\n", i, i, domain, i
|
|
158
|
+
}
|
|
159
|
+
printf "dn: cn=rc-users,ou=groups,%s\nobjectClass: top\nobjectClass: posixGroup\ncn: rc-users\ngidNumber: 5000\n", base
|
|
160
|
+
for (i = 1; i <= n; i++) printf "memberUid: user%d\n", i
|
|
161
|
+
if (groups == "on") {
|
|
162
|
+
group("rocket-chat", 5001, 1, n - 1)
|
|
163
|
+
group("rocket-admin", 5002, 1, n < 1 ? 0 : 1)
|
|
164
|
+
group("employee", 5003, 1, n)
|
|
165
|
+
}
|
|
166
|
+
printf "\n"
|
|
167
|
+
}' > "$1"
|
|
168
|
+
`;
|
|
169
|
+
const GENERATOR_PATH = '/houston/gen-users.sh';
|
|
170
|
+
/** Generate the directory, then hand over to the image's own entrypoint, as its CMD does. */
|
|
171
|
+
const GENERATE_THEN_RUN = `sh ${GENERATOR_PATH} ${BOOTSTRAP_PATH} && exec /usr/local/bin/docker-entrypoint.sh slapd`;
|
|
172
|
+
function generated(it) {
|
|
173
|
+
return it.users > exports.SHIPPED_USERS_MAX;
|
|
174
|
+
}
|
|
175
|
+
/** What the generator reads: the same intent `ldif()` renders. */
|
|
176
|
+
function generatorEnv(it) {
|
|
177
|
+
return {
|
|
178
|
+
HOUSTON_LDAP_USERS: String(it.users),
|
|
179
|
+
HOUSTON_LDAP_BASE_DN: it.baseDn,
|
|
180
|
+
HOUSTON_LDAP_DOMAIN: it.domain,
|
|
181
|
+
HOUSTON_LDAP_GROUPS: it.groups ? 'on' : 'off',
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* `--set directory=ad`: Samba answering as Active Directory, without the rest of a domain
|
|
186
|
+
* controller. Pinned by digest because the image publishes only `latest`.
|
|
187
|
+
*/
|
|
188
|
+
const AD_IMAGE = 'smblds/smblds@sha256:c9e6dedd718cc541ff5b14c7044fc14ce3d3a8789e4468552a9a17c24e118d62';
|
|
189
|
+
const AD_HOST = 'samba-ad';
|
|
190
|
+
/** The image's default, which provisioning holds to AD's complexity rules. */
|
|
191
|
+
const AD_ADMIN_PASSWORD = 'Passw0rd';
|
|
192
|
+
const AD_SEED_PATH = '/houston/ad-seed.sh';
|
|
193
|
+
const AD_CERTS_DIR = '/houston/certs';
|
|
194
|
+
/** AD's LDAP_MATCHING_RULE_IN_CHAIN: membership through any depth of nested groups. */
|
|
195
|
+
const IN_CHAIN = '1.2.840.113556.1.4.1941';
|
|
196
|
+
/**
|
|
197
|
+
* The AD directory's seed, which the image runs after it provisions and before samba starts,
|
|
198
|
+
* as it runs every executable in /entrypoint.d. Offline `ldbadd`, because one `samba-tool`
|
|
199
|
+
* per user takes minutes; this way 1,600 users seed in 29 s and 20,000 in about five minutes
|
|
200
|
+
* (measured). Users carry sAMAccountName, a UPN and `unicodePwd` (the password quoted,
|
|
201
|
+
* UTF-16LE, base64, which awk computes itself). With groups=on, rocket-chat holds staff, which
|
|
202
|
+
* holds every user but the last, so a login is allowed only through the nesting. Once only:
|
|
203
|
+
* on a restart the directory is already there, and only houston's certificate is put back.
|
|
204
|
+
*/
|
|
205
|
+
exports.AD_SEED = String.raw `#!/bin/sh
|
|
206
|
+
set -eu
|
|
207
|
+
PRIVATE=${'$'}{HOUSTON_AD_PRIVATE:-/var/lib/samba/private}
|
|
208
|
+
if [ -f /houston/certs/ldap.key ]; then
|
|
209
|
+
# Samba serves LDAPS and StartTLS with these when they are there, and makes its own if not.
|
|
210
|
+
mkdir -p "$PRIVATE/tls"
|
|
211
|
+
install -m 0600 /houston/certs/ldap.key "$PRIVATE/tls/key.pem"
|
|
212
|
+
install -m 0644 /houston/certs/ldap.crt "$PRIVATE/tls/cert.pem"
|
|
213
|
+
install -m 0644 /houston/certs/ca.crt "$PRIVATE/tls/ca.pem"
|
|
214
|
+
fi
|
|
215
|
+
[ -f "$PRIVATE/houston-seeded" ] && exit 0
|
|
216
|
+
awk -v n="$HOUSTON_LDAP_USERS" -v base="$HOUSTON_LDAP_BASE_DN" -v domain="$HOUSTON_LDAP_DOMAIN" \
|
|
217
|
+
-v groups="$HOUSTON_LDAP_GROUPS" -v service="$HOUSTON_LDAP_SERVICE" '
|
|
218
|
+
BEGIN {
|
|
219
|
+
B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
|
220
|
+
for (c = 32; c < 127; c++) ORD[sprintf("%c", c)] = c
|
|
221
|
+
}
|
|
222
|
+
function pwd(p, s, i, n, b, o, x) {
|
|
223
|
+
s = "\"" p "\""; n = 0
|
|
224
|
+
for (i = 1; i <= length(s); i++) { b[n++] = ORD[substr(s, i, 1)]; b[n++] = 0 }
|
|
225
|
+
o = ""
|
|
226
|
+
for (i = 0; i < n; i += 3) {
|
|
227
|
+
x = b[i] * 65536 + (i + 1 < n ? b[i + 1] : 0) * 256 + (i + 2 < n ? b[i + 2] : 0)
|
|
228
|
+
o = o substr(B64, int(x / 262144) % 64 + 1, 1) substr(B64, int(x / 4096) % 64 + 1, 1)
|
|
229
|
+
o = o (i + 1 < n ? substr(B64, int(x / 64) % 64 + 1, 1) : "=")
|
|
230
|
+
o = o (i + 2 < n ? substr(B64, x % 64 + 1, 1) : "=")
|
|
231
|
+
}
|
|
232
|
+
return o
|
|
233
|
+
}
|
|
234
|
+
function user(name, parent, given, sn) {
|
|
235
|
+
printf "dn: CN=%s,%s,%s\nobjectClass: user\nsAMAccountName: %s\n", name, parent, base, name
|
|
236
|
+
printf "userPrincipalName: %s@%s\ngivenName: %s\nsn: %s\n", name, domain, given, sn
|
|
237
|
+
printf "displayName: %s %s\nmail: %s@%s\n", given, sn, name, domain
|
|
238
|
+
printf "userAccountControl: 512\nunicodePwd:: %s\n\n", pwd(name)
|
|
239
|
+
}
|
|
240
|
+
function group(cn, first, last, i) {
|
|
241
|
+
printf "dn: CN=%s,OU=Groups,%s\nobjectClass: group\nsAMAccountName: %s\n", cn, base, cn
|
|
242
|
+
for (i = first; i <= last; i++) printf "member: CN=user%d,OU=Users,%s\n", i, base
|
|
243
|
+
printf "\n"
|
|
244
|
+
}
|
|
245
|
+
BEGIN {
|
|
246
|
+
printf "dn: OU=Users,%s\nobjectClass: organizationalUnit\nou: Users\n\n", base
|
|
247
|
+
printf "dn: OU=Groups,%s\nobjectClass: organizationalUnit\nou: Groups\n\n", base
|
|
248
|
+
for (i = 1; i <= n; i++) user("user" i, "OU=Users", "User", i)
|
|
249
|
+
if (service == "on") user("readonly", "CN=Users", "Read", "Only")
|
|
250
|
+
group("rc-users", 1, n)
|
|
251
|
+
if (groups == "on") {
|
|
252
|
+
group("staff", 1, n - 1)
|
|
253
|
+
printf "dn: CN=rocket-chat,OU=Groups,%s\nobjectClass: group\n", base
|
|
254
|
+
printf "sAMAccountName: rocket-chat\nmember: CN=staff,OU=Groups,%s\n\n", base
|
|
255
|
+
group("rocket-admin", 1, n < 1 ? 0 : 1)
|
|
256
|
+
group("employee", 1, n)
|
|
257
|
+
}
|
|
258
|
+
}' > "$PRIVATE/houston-seed.ldif"
|
|
259
|
+
ldbadd -H "$PRIVATE/sam.ldb" "$PRIVATE/houston-seed.ldif" > /dev/null
|
|
260
|
+
rm -f "$PRIVATE/houston-seed.ldif"
|
|
261
|
+
touch "$PRIVATE/houston-seeded"
|
|
262
|
+
`;
|
|
263
|
+
/** Put the seed where the image runs it (a workspace's files are 0644), then start as it does. */
|
|
264
|
+
const INSTALL_SEED_THEN_RUN = `install -m 0755 ${AD_SEED_PATH} /entrypoint.d/50-houston-seed && ` +
|
|
265
|
+
'exec /sbin/tini -g -- /entrypoint.sh';
|
|
266
|
+
function isAd(it) {
|
|
267
|
+
return it.directory === 'ad';
|
|
268
|
+
}
|
|
269
|
+
/** The service Rocket.Chat dials, phpLDAPadmin reads and the certificate is issued for. */
|
|
270
|
+
function hostOf(it) {
|
|
271
|
+
return isAd(it) ? AD_HOST : 'openldap';
|
|
272
|
+
}
|
|
273
|
+
/** The directory's administrator, as phpLDAPadmin is signed in to: a DN and its password. */
|
|
274
|
+
function adminLogin(it) {
|
|
275
|
+
return isAd(it)
|
|
276
|
+
? [`CN=Administrator,CN=Users,${it.baseDn}`, AD_ADMIN_PASSWORD]
|
|
277
|
+
: [`cn=admin,${it.baseDn}`, it.adminPassword];
|
|
278
|
+
}
|
|
279
|
+
/** phpLDAPadmin 2's settings, one source for both runtimes. */
|
|
280
|
+
function uiEnv(it) {
|
|
281
|
+
const [dn, password] = adminLogin(it);
|
|
282
|
+
return {
|
|
283
|
+
LDAP_HOST: hostOf(it),
|
|
284
|
+
LDAP_BASE_DN: it.baseDn,
|
|
285
|
+
// The bind it reads the schema with before anyone has signed in: the same throwaway
|
|
286
|
+
// admin the notes print, on a directory reachable only inside the workspace.
|
|
287
|
+
LDAP_USERNAME: dn,
|
|
288
|
+
LDAP_PASSWORD: password,
|
|
289
|
+
// Signed in with the whole DN, as the notes and the guide say (2.x defaults to uid)...
|
|
290
|
+
LDAP_LOGIN_ATTR: 'dn',
|
|
291
|
+
LDAP_LOGIN_ATTR_DESC: 'Login DN',
|
|
292
|
+
// ...and only an entry of these classes may sign in (2.x defaults to posixAccount,
|
|
293
|
+
// which neither administrator is).
|
|
294
|
+
LDAP_LOGIN_OBJECTCLASS: isAd(it) ? 'user' : 'organizationalRole',
|
|
295
|
+
// Samba has no entryUUID; AD names its entries by objectGUID.
|
|
296
|
+
...(isAd(it) ? { LDAP_GUIDKEY: 'objectguid' } : {}),
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
/** The image's environment, and what the seed reads. */
|
|
300
|
+
function adEnv(it) {
|
|
301
|
+
return {
|
|
302
|
+
REALM: it.domain.toUpperCase(),
|
|
303
|
+
DOMAIN: (it.domain.split('.')[0] ?? '').toUpperCase().slice(0, 15),
|
|
304
|
+
ADMINPASS: AD_ADMIN_PASSWORD,
|
|
305
|
+
// Simple binds over plain 389, as the openldap flavour allows, and passwords like user1.
|
|
306
|
+
INSECURE_LDAP: 'true',
|
|
307
|
+
INSECURE_PASSWORDSETTINGS: 'true',
|
|
308
|
+
HOUSTON_LDAP_USERS: String(it.users),
|
|
309
|
+
HOUSTON_LDAP_BASE_DN: it.baseDn,
|
|
310
|
+
HOUSTON_LDAP_DOMAIN: it.domain,
|
|
311
|
+
HOUSTON_LDAP_GROUPS: it.groups ? 'on' : 'off',
|
|
312
|
+
HOUSTON_LDAP_SERVICE: it.bind === 'service' ? 'on' : 'off',
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Keycloak's LDAP user federation for this directory (`--set idp=saml|oidc`): the users sign
|
|
317
|
+
* in at Keycloak with their directory password, and Keycloak hands Rocket.Chat a SAML or OIDC
|
|
318
|
+
* login for them. Read-only, imported on first sign-in. The attribute mappers are written out
|
|
319
|
+
* because a realm import creates none (measured: every login failed with "User returned from
|
|
320
|
+
* LDAP has null username"), and the group mapper shows the directory's groups in Keycloak,
|
|
321
|
+
* through AD's nesting where there is one. Keycloak dials the directory over plain 389, which
|
|
322
|
+
* both flavours serve whatever `tls` is.
|
|
323
|
+
*/
|
|
324
|
+
function federation(it) {
|
|
325
|
+
const ad = isAd(it);
|
|
326
|
+
const [bindDn, bindCredential] = bindOf(it);
|
|
327
|
+
const attribute = (name, ldap, model) => ({
|
|
328
|
+
name,
|
|
329
|
+
providerId: 'user-attribute-ldap-mapper',
|
|
330
|
+
config: {
|
|
331
|
+
'ldap.attribute': [ldap],
|
|
332
|
+
'user.model.attribute': [model],
|
|
333
|
+
'read.only': ['true'],
|
|
334
|
+
'always.read.value.from.ldap': ['true'],
|
|
335
|
+
'is.mandatory.in.ldap': [model === 'email' ? 'false' : 'true'],
|
|
336
|
+
},
|
|
337
|
+
});
|
|
338
|
+
const groups = {
|
|
339
|
+
name: 'groups',
|
|
340
|
+
providerId: 'group-ldap-mapper',
|
|
341
|
+
config: {
|
|
342
|
+
'groups.dn': [ad ? `OU=Groups,${it.baseDn}` : `ou=groups,${it.baseDn}`],
|
|
343
|
+
'group.name.ldap.attribute': ['cn'],
|
|
344
|
+
'group.object.classes': [ad ? 'group' : 'posixGroup'],
|
|
345
|
+
'preserve.group.inheritance': [ad ? 'true' : 'false'],
|
|
346
|
+
'membership.ldap.attribute': [ad ? 'member' : 'memberUid'],
|
|
347
|
+
'membership.attribute.type': [ad ? 'DN' : 'UID'],
|
|
348
|
+
'membership.user.ldap.attribute': [ad ? 'sAMAccountName' : 'uid'],
|
|
349
|
+
'user.roles.retrieve.strategy': [
|
|
350
|
+
ad ? 'LOAD_GROUPS_BY_MEMBER_ATTRIBUTE_RECURSIVELY' : 'LOAD_GROUPS_BY_MEMBER_ATTRIBUTE',
|
|
351
|
+
],
|
|
352
|
+
mode: ['READ_ONLY'],
|
|
353
|
+
'groups.path': ['/'],
|
|
354
|
+
'ignore.missing.groups': ['false'],
|
|
355
|
+
'drop.non.existing.groups.during.sync': ['false'],
|
|
356
|
+
},
|
|
357
|
+
};
|
|
358
|
+
return {
|
|
359
|
+
'org.keycloak.storage.UserStorageProvider': [
|
|
360
|
+
{
|
|
361
|
+
name: 'directory',
|
|
362
|
+
providerId: 'ldap',
|
|
363
|
+
config: {
|
|
364
|
+
enabled: ['true'],
|
|
365
|
+
vendor: [ad ? 'ad' : 'other'],
|
|
366
|
+
connectionUrl: [`ldap://${hostOf(it)}:389`],
|
|
367
|
+
usersDn: [ad ? `OU=Users,${it.baseDn}` : `ou=Users,${it.baseDn}`],
|
|
368
|
+
bindDn: [bindDn],
|
|
369
|
+
bindCredential: [bindCredential],
|
|
370
|
+
authType: ['simple'],
|
|
371
|
+
usernameLDAPAttribute: [ad ? 'sAMAccountName' : 'uid'],
|
|
372
|
+
rdnLDAPAttribute: [ad ? 'cn' : 'uid'],
|
|
373
|
+
uuidLDAPAttribute: [ad ? 'objectGUID' : 'entryUUID'],
|
|
374
|
+
userObjectClasses: [
|
|
375
|
+
ad ? 'person, organizationalPerson, user' : 'inetOrgPerson, posixAccount',
|
|
376
|
+
],
|
|
377
|
+
searchScope: ['2'],
|
|
378
|
+
editMode: ['READ_ONLY'],
|
|
379
|
+
importEnabled: ['true'],
|
|
380
|
+
syncRegistrations: ['false'],
|
|
381
|
+
trustEmail: ['true'],
|
|
382
|
+
pagination: ['true'],
|
|
383
|
+
},
|
|
384
|
+
subComponents: {
|
|
385
|
+
'org.keycloak.storage.ldap.mappers.LDAPStorageMapper': [
|
|
386
|
+
attribute('username', ad ? 'sAMAccountName' : 'uid', 'username'),
|
|
387
|
+
attribute('email', 'mail', 'email'),
|
|
388
|
+
attribute('first name', ad ? 'givenName' : 'cn', 'firstName'),
|
|
389
|
+
attribute('last name', 'sn', 'lastName'),
|
|
390
|
+
groups,
|
|
391
|
+
],
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
],
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
/** `ports`: the workspace's, so ldap's own Keycloak takes the saml or oidc port it was given. */
|
|
398
|
+
function idpParts(it, ports) {
|
|
399
|
+
if (it.idp === 'none')
|
|
400
|
+
return null;
|
|
401
|
+
const port = (0, common_1.presetPort)(it.idp, 0, ports);
|
|
402
|
+
const host = `http://${it.idpHost}:${String(port)}`;
|
|
403
|
+
const realmBase = `${host}/realms/${keycloak.REALM}`;
|
|
404
|
+
const saml = it.idp === 'saml';
|
|
405
|
+
const extra = {
|
|
406
|
+
components: federation(it),
|
|
407
|
+
...(it.mfa
|
|
408
|
+
? {
|
|
409
|
+
// A default action is added to every user Keycloak creates, imported ones included
|
|
410
|
+
// (measured: the first sign-in answers "Account is not fully set up").
|
|
411
|
+
requiredActions: [
|
|
412
|
+
{
|
|
413
|
+
alias: 'CONFIGURE_TOTP',
|
|
414
|
+
name: 'Configure OTP',
|
|
415
|
+
providerId: 'CONFIGURE_TOTP',
|
|
416
|
+
enabled: true,
|
|
417
|
+
defaultAction: true,
|
|
418
|
+
priority: 10,
|
|
419
|
+
config: {},
|
|
420
|
+
},
|
|
421
|
+
],
|
|
422
|
+
}
|
|
423
|
+
: {}),
|
|
424
|
+
};
|
|
425
|
+
const client = saml ? keycloak.samlClient() : keycloak.oidcClient(it.idpHost, port);
|
|
426
|
+
const realm = keycloak.realmJson([client], 0, '', extra);
|
|
427
|
+
const setting = `Accounts_OAuth_Custom-${keycloak.capitalize(keycloak.OIDC_PROVIDER)}`;
|
|
428
|
+
const [oidcEnv, oidcSettings] = keycloak.oauthSettings(realmBase, setting);
|
|
429
|
+
const button = saml ? 'Keycloak SSO' : 'Keycloak (OIDC)';
|
|
430
|
+
return {
|
|
431
|
+
port,
|
|
432
|
+
realm,
|
|
433
|
+
env: saml ? keycloak.samlSettings(`${realmBase}/protocol/saml`) : oidcEnv,
|
|
434
|
+
postReady: saml
|
|
435
|
+
? [
|
|
436
|
+
{
|
|
437
|
+
action: 'saml_idp_cert',
|
|
438
|
+
descriptor_url: `http://localhost:${String(port)}/realms/${keycloak.REALM}/protocol/saml/descriptor`,
|
|
439
|
+
setting: 'SAML_Custom_Default_cert',
|
|
440
|
+
enable_setting: 'SAML_Custom_Default',
|
|
441
|
+
},
|
|
442
|
+
{ action: 'keycloak_master_ssl_off', service: 'keycloak' },
|
|
443
|
+
]
|
|
444
|
+
: [
|
|
445
|
+
{ action: 'keycloak_master_ssl_off', service: 'keycloak', port },
|
|
446
|
+
{
|
|
447
|
+
action: 'create_oauth_provider',
|
|
448
|
+
name: keycloak.capitalize(keycloak.OIDC_PROVIDER),
|
|
449
|
+
settings: oidcSettings,
|
|
450
|
+
},
|
|
451
|
+
],
|
|
452
|
+
notes: [
|
|
453
|
+
// One string per point: the GUI reads a line indented by four spaces as something to
|
|
454
|
+
// paste, and wrapped prose written that way came out as a row of Copy boxes.
|
|
455
|
+
`SSO: Keycloak signs in this directory's users. Click '${button}' and sign in as user1 / user1, the same user LDAP login uses; Rocket.Chat matches the two by email.`,
|
|
456
|
+
...(it.mfa
|
|
457
|
+
? ['Keycloak asks each user to set up an authenticator app at their first sign-in.']
|
|
458
|
+
: []),
|
|
459
|
+
...(!saml && it.idpHost === 'keycloak'
|
|
460
|
+
? [
|
|
461
|
+
'A browser on the machine running houston needs a hosts entry for Keycloak:',
|
|
462
|
+
' 127.0.0.1 keycloak',
|
|
463
|
+
]
|
|
464
|
+
: []),
|
|
465
|
+
...(it.idpHost === 'localhost' || it.idpHost === 'keycloak'
|
|
466
|
+
? [keycloak.FROM_ANOTHER_COMPUTER]
|
|
467
|
+
: []),
|
|
468
|
+
`Keycloak admin console: ${host} (admin / admin, realm '${keycloak.REALM}'; the users are under User federation > directory)`,
|
|
469
|
+
],
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
/** The image's read-only user (LDAP_READONLY_USER), for `--set bind=service`. */
|
|
473
|
+
const READONLY_USER = 'readonly';
|
|
474
|
+
const READONLY_PASSWORD = 'readonly';
|
|
475
|
+
function asParams(intent) {
|
|
476
|
+
// The two lab params only when set, so the default's params read as they always have.
|
|
477
|
+
return {
|
|
478
|
+
users: intent.users,
|
|
479
|
+
domain: intent.domain,
|
|
480
|
+
base_dn: intent.baseDn,
|
|
481
|
+
...(intent.groups ? { groups: 'on' } : {}),
|
|
482
|
+
...(intent.bind === 'service' ? { bind: 'service' } : {}),
|
|
483
|
+
...(intent.tls === 'none' ? {} : { tls: intent.tls, trust: intent.trust }),
|
|
484
|
+
...(intent.directory === 'ad' ? { directory: 'ad' } : {}),
|
|
485
|
+
...(intent.idp === 'none'
|
|
486
|
+
? {}
|
|
487
|
+
: { idp: intent.idp, idp_host: intent.idpHost, ...(intent.mfa ? { mfa: 'on' } : {}) }),
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
/** Which users each lab group holds: rocket-chat leaves the last one out, to be refused. */
|
|
491
|
+
function labMembers(group, users) {
|
|
492
|
+
const all = Array.from({ length: users }, (_, index) => index + 1);
|
|
493
|
+
if (group === 'rocket-admin')
|
|
494
|
+
return all.slice(0, 1);
|
|
495
|
+
if (group === 'rocket-chat')
|
|
496
|
+
return all.slice(0, Math.max(0, users - 1));
|
|
497
|
+
return all;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* slapd makes `cn=admin,<base>` the root account, and neither osixia nor its replacement
|
|
501
|
+
* creates its entry. phpLDAPadmin 1.2.5 signed in on the bind alone; 2.x looks the DN up and
|
|
502
|
+
* refuses one that does not exist ("rootdn to login (not supported)"). Its classes are the ones
|
|
503
|
+
* `LDAP_LOGIN_OBJECTCLASS` admits; Rocket.Chat's `(objectclass=inetOrgPerson)` never syncs it.
|
|
504
|
+
*/
|
|
505
|
+
function adminEntry(baseDn, password) {
|
|
506
|
+
return (`dn: cn=admin,${baseDn}\nobjectClass: simpleSecurityObject\n` +
|
|
507
|
+
`objectClass: organizationalRole\ncn: admin\nuserPassword: ${password}\n`);
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* The image seeds `ou=people` beside `ou=groups`, and houston's users live in `ou=Users`: an
|
|
511
|
+
* empty second people branch in every tree. `ldapadd` honours an explicit changetype.
|
|
512
|
+
*/
|
|
513
|
+
function emptyPeopleGone(baseDn) {
|
|
514
|
+
return `dn: ou=people,${baseDn}\nchangetype: delete\n`;
|
|
515
|
+
}
|
|
516
|
+
function ldif(it) {
|
|
517
|
+
const { baseDn, domain, users } = it;
|
|
518
|
+
const blocks = [
|
|
519
|
+
adminEntry(baseDn, it.adminPassword),
|
|
520
|
+
emptyPeopleGone(baseDn),
|
|
521
|
+
`dn: ou=Users,${baseDn}\nobjectClass: organizationalUnit\nou: Users\n`,
|
|
522
|
+
`dn: ou=groups,${baseDn}\nobjectClass: organizationalUnit\nou: groups\n`,
|
|
523
|
+
];
|
|
524
|
+
for (let i = 1; i <= users; i += 1) {
|
|
525
|
+
const uid = `user${String(i)}`;
|
|
526
|
+
blocks.push(`dn: uid=${uid},ou=Users,${baseDn}\n` +
|
|
527
|
+
'objectClass: inetOrgPerson\n' +
|
|
528
|
+
'objectClass: posixAccount\n' +
|
|
529
|
+
`cn: User ${String(i)}\n` +
|
|
530
|
+
`sn: ${String(i)}\n` +
|
|
531
|
+
`uid: ${uid}\n` +
|
|
532
|
+
`uidNumber: ${String(1000 + i)}\n` +
|
|
533
|
+
`gidNumber: ${GID}\n` +
|
|
534
|
+
`homeDirectory: /home/${uid}\n` +
|
|
535
|
+
`mail: ${uid}@${domain}\n` +
|
|
536
|
+
`userPassword: ${uid}\n`);
|
|
537
|
+
}
|
|
538
|
+
let members = '';
|
|
539
|
+
for (let i = 1; i <= users; i += 1)
|
|
540
|
+
members += `memberUid: user${String(i)}\n`;
|
|
541
|
+
blocks.push(`dn: cn=${GROUP_CN},ou=groups,${baseDn}\n` +
|
|
542
|
+
'objectClass: top\n' +
|
|
543
|
+
'objectClass: posixGroup\n' +
|
|
544
|
+
`cn: ${GROUP_CN}\n` +
|
|
545
|
+
`gidNumber: ${GID}\n` +
|
|
546
|
+
`${members}`);
|
|
547
|
+
if (it.groups) {
|
|
548
|
+
for (const [cn, gid] of LAB_GROUPS) {
|
|
549
|
+
blocks.push(`dn: cn=${cn},ou=groups,${baseDn}\n` +
|
|
550
|
+
'objectClass: top\n' +
|
|
551
|
+
'objectClass: posixGroup\n' +
|
|
552
|
+
`cn: ${cn}\n` +
|
|
553
|
+
`gidNumber: ${gid}\n` +
|
|
554
|
+
labMembers(cn, users)
|
|
555
|
+
.map((i) => `memberUid: user${String(i)}\n`)
|
|
556
|
+
.join(''));
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
return `${blocks.join('\n')}\n`;
|
|
560
|
+
}
|
|
561
|
+
function intent(params) {
|
|
562
|
+
const users = (0, common_1.intParam)(params, 'users', 5);
|
|
563
|
+
const domain = (0, common_1.strParam)(params, 'domain', 'example.com');
|
|
564
|
+
const directory = (0, common_1.choiceParam)(params, 'directory', ['openldap', 'ad']);
|
|
565
|
+
const idp = (0, common_1.choiceParam)(params, 'idp', ['none', 'saml', 'oidc']);
|
|
566
|
+
const mfa = (0, common_1.choiceParam)(params, 'mfa', ['off', 'on']) === 'on';
|
|
567
|
+
if (mfa && idp === 'none') {
|
|
568
|
+
throw new Error('--set mfa=on is asked of Keycloak at SSO sign-in: add --set idp=saml or idp=oidc');
|
|
569
|
+
}
|
|
570
|
+
// AD spells its naming attributes in capitals, and Rocket.Chat compares member DNs as text.
|
|
571
|
+
const dc = directory === 'ad' ? 'DC' : 'dc';
|
|
572
|
+
const baseDn = domain
|
|
573
|
+
.split('.')
|
|
574
|
+
.map((part) => `${dc}=${part}`)
|
|
575
|
+
.join(',');
|
|
576
|
+
return {
|
|
577
|
+
users,
|
|
578
|
+
domain,
|
|
579
|
+
baseDn,
|
|
580
|
+
adminPassword: 'admin',
|
|
581
|
+
groups: (0, common_1.choiceParam)(params, 'groups', ['off', 'on']) === 'on',
|
|
582
|
+
bind: (0, common_1.choiceParam)(params, 'bind', ['admin', 'service']),
|
|
583
|
+
tls: (0, common_1.choiceParam)(params, 'tls', ['none', 'ldaps', 'starttls']),
|
|
584
|
+
trust: (0, common_1.choiceParam)(params, 'trust', ['houston', 'none']),
|
|
585
|
+
directory,
|
|
586
|
+
idp,
|
|
587
|
+
mfa,
|
|
588
|
+
idpHost: (0, common_1.strParam)(params, 'idp_host', idp === 'oidc' ? 'keycloak' : 'localhost'),
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
/** Rocket.Chat LDAP settings shared by Compose and Kubernetes. */
|
|
592
|
+
function envFor(it) {
|
|
593
|
+
if (isAd(it))
|
|
594
|
+
return adRocketChatEnv(it);
|
|
595
|
+
return {
|
|
596
|
+
OVERWRITE_SETTING_LDAP_Enable: 'true',
|
|
597
|
+
// Generic OpenLDAP, NOT Active Directory. Without this, RC defaults to server type
|
|
598
|
+
// "ad" and searches sAMAccountName instead of our uid field, so every LDAP login
|
|
599
|
+
// fails with "User not found".
|
|
600
|
+
OVERWRITE_SETTING_LDAP_Server_Type: '',
|
|
601
|
+
OVERWRITE_SETTING_LDAP_Host: 'openldap',
|
|
602
|
+
OVERWRITE_SETTING_LDAP_Port: '389',
|
|
603
|
+
OVERWRITE_SETTING_LDAP_BaseDN: it.baseDn,
|
|
604
|
+
OVERWRITE_SETTING_LDAP_Authentication: 'true',
|
|
605
|
+
OVERWRITE_SETTING_LDAP_Authentication_UserDN: bindOf(it)[0],
|
|
606
|
+
OVERWRITE_SETTING_LDAP_Authentication_Password: bindOf(it)[1],
|
|
607
|
+
OVERWRITE_SETTING_LDAP_User_Search_Filter: '(objectclass=inetOrgPerson)',
|
|
608
|
+
OVERWRITE_SETTING_LDAP_User_Search_Field: 'uid',
|
|
609
|
+
OVERWRITE_SETTING_LDAP_User_Search_Scope: 'sub',
|
|
610
|
+
OVERWRITE_SETTING_LDAP_Unique_Identifier_Field: 'uid',
|
|
611
|
+
// Keep local login working so admin/admin123 (and houston's API) still work.
|
|
612
|
+
OVERWRITE_SETTING_LDAP_Login_Fallback: 'true',
|
|
613
|
+
// No SMTP in the repro, so email-2FA on a new LDAP user's first login would block it
|
|
614
|
+
// with an OTP that goes nowhere. Turn it off so you can actually log in as
|
|
615
|
+
// user1/user1.
|
|
616
|
+
OVERWRITE_SETTING_Accounts_TwoFactorAuthentication_By_Email_Enabled: 'false',
|
|
617
|
+
// Only members of `rocket-chat` may log in. posixGroup with memberUid, matched against
|
|
618
|
+
// the username, so no memberOf overlay is needed.
|
|
619
|
+
...(it.groups
|
|
620
|
+
? {
|
|
621
|
+
OVERWRITE_SETTING_LDAP_Group_Filter_Enable: 'true',
|
|
622
|
+
OVERWRITE_SETTING_LDAP_Group_Filter_ObjectClass: 'posixGroup',
|
|
623
|
+
OVERWRITE_SETTING_LDAP_Group_Filter_Group_Id_Attribute: 'cn',
|
|
624
|
+
OVERWRITE_SETTING_LDAP_Group_Filter_Group_Member_Attribute: 'memberUid',
|
|
625
|
+
OVERWRITE_SETTING_LDAP_Group_Filter_Group_Member_Format: '#{username}',
|
|
626
|
+
OVERWRITE_SETTING_LDAP_Group_Filter_Group_Name: 'rocket-chat',
|
|
627
|
+
...syncEnv(it),
|
|
628
|
+
}
|
|
629
|
+
: {}),
|
|
630
|
+
// The CA itself is added by `withCertificate`, once houston has issued the certificate.
|
|
631
|
+
...(it.tls === 'none'
|
|
632
|
+
? {}
|
|
633
|
+
: {
|
|
634
|
+
OVERWRITE_SETTING_LDAP_Port: it.tls === 'ldaps' ? '636' : '389',
|
|
635
|
+
OVERWRITE_SETTING_LDAP_Encryption: it.tls === 'ldaps' ? 'ssl' : 'tls',
|
|
636
|
+
OVERWRITE_SETTING_LDAP_Reject_Unauthorized: 'true',
|
|
637
|
+
}),
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Rocket.Chat against the AD flavour. Server type `ad` makes Rocket.Chat read the `LDAP_AD_*`
|
|
642
|
+
* copies of the search, username, email and name fields, not the plain ones; the unique
|
|
643
|
+
* identifier and the search filter it reads either way. With groups=on the login filter asks
|
|
644
|
+
* for rocket-chat membership through any depth of nesting, which only AD's in-chain rule does.
|
|
645
|
+
*/
|
|
646
|
+
function adRocketChatEnv(it) {
|
|
647
|
+
const person = '(objectCategory=person)(objectClass=user)';
|
|
648
|
+
const enabled = '(!(userAccountControl:1.2.840.113556.1.4.803:=2))';
|
|
649
|
+
const chain = it.groups ? `(memberOf:${IN_CHAIN}:=CN=rocket-chat,OU=Groups,${it.baseDn})` : '';
|
|
650
|
+
return {
|
|
651
|
+
OVERWRITE_SETTING_LDAP_Enable: 'true',
|
|
652
|
+
OVERWRITE_SETTING_LDAP_Server_Type: 'ad',
|
|
653
|
+
OVERWRITE_SETTING_LDAP_Host: AD_HOST,
|
|
654
|
+
OVERWRITE_SETTING_LDAP_Port: '389',
|
|
655
|
+
OVERWRITE_SETTING_LDAP_BaseDN: it.baseDn,
|
|
656
|
+
OVERWRITE_SETTING_LDAP_Authentication: 'true',
|
|
657
|
+
OVERWRITE_SETTING_LDAP_Authentication_UserDN: bindOf(it)[0],
|
|
658
|
+
OVERWRITE_SETTING_LDAP_Authentication_Password: bindOf(it)[1],
|
|
659
|
+
OVERWRITE_SETTING_LDAP_User_Search_Filter: `(&${person}${enabled}${chain})`,
|
|
660
|
+
OVERWRITE_SETTING_LDAP_User_Search_Scope: 'sub',
|
|
661
|
+
OVERWRITE_SETTING_LDAP_AD_User_Search_Field: 'sAMAccountName',
|
|
662
|
+
OVERWRITE_SETTING_LDAP_AD_Username_Field: 'sAMAccountName',
|
|
663
|
+
OVERWRITE_SETTING_LDAP_AD_Email_Field: 'mail',
|
|
664
|
+
OVERWRITE_SETTING_LDAP_AD_Name_Field: 'displayName',
|
|
665
|
+
OVERWRITE_SETTING_LDAP_Unique_Identifier_Field: 'objectGUID',
|
|
666
|
+
OVERWRITE_SETTING_LDAP_Login_Fallback: 'true',
|
|
667
|
+
OVERWRITE_SETTING_Accounts_TwoFactorAuthentication_By_Email_Enabled: 'false',
|
|
668
|
+
...(it.groups ? syncEnv(it) : {}),
|
|
669
|
+
...(it.tls === 'none'
|
|
670
|
+
? {}
|
|
671
|
+
: {
|
|
672
|
+
OVERWRITE_SETTING_LDAP_Port: it.tls === 'ldaps' ? '636' : '389',
|
|
673
|
+
OVERWRITE_SETTING_LDAP_Encryption: it.tls === 'ldaps' ? 'ssl' : 'tls',
|
|
674
|
+
OVERWRITE_SETTING_LDAP_Reject_Unauthorized: 'true',
|
|
675
|
+
}),
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
/** Who Rocket.Chat (and Keycloak, with idp) binds to the directory as: DN and password. */
|
|
679
|
+
function bindOf(it) {
|
|
680
|
+
if (isAd(it)) {
|
|
681
|
+
return it.bind === 'service'
|
|
682
|
+
? [`CN=${READONLY_USER},CN=Users,${it.baseDn}`, READONLY_USER]
|
|
683
|
+
: [`CN=Administrator,CN=Users,${it.baseDn}`, AD_ADMIN_PASSWORD];
|
|
684
|
+
}
|
|
685
|
+
return it.bind === 'service'
|
|
686
|
+
? [`cn=${READONLY_USER},${it.baseDn}`, READONLY_PASSWORD]
|
|
687
|
+
: [`cn=admin,${it.baseDn}`, it.adminPassword];
|
|
688
|
+
}
|
|
689
|
+
/** The service name the directory's certificate is issued for; none means openldap. */
|
|
690
|
+
function directoryHost(extra) {
|
|
691
|
+
return typeof extra.directory_host === 'string' ? extra.directory_host : undefined;
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* The directory's certificate, which houston's create issues from its own CA when the preset
|
|
695
|
+
* records `directory_tls`: Compose files beside the LDIF, or a Kubernetes Secret, and the CA
|
|
696
|
+
* for Rocket.Chat unless `trust=none`. Pure, so the merge and the specs need no openssl.
|
|
697
|
+
*/
|
|
698
|
+
function withCertificate(pre, cert, runtime) {
|
|
699
|
+
const out = { ...pre, env: { ...pre.env }, files: [...pre.files] };
|
|
700
|
+
if (runtime === 'kubernetes') {
|
|
701
|
+
out.kubernetesManifests = [
|
|
702
|
+
...pre.kubernetesManifests,
|
|
703
|
+
(0, common_1.safeDump)({
|
|
704
|
+
apiVersion: 'v1',
|
|
705
|
+
kind: 'Secret',
|
|
706
|
+
metadata: { name: TLS_SECRET, labels: { 'houston.io/repro': '__HOUSTON_NAME__' } },
|
|
707
|
+
type: 'Opaque',
|
|
708
|
+
stringData: { 'ldap.crt': cert.crt, 'ldap.key': cert.key, 'ca.crt': cert.ca },
|
|
709
|
+
}),
|
|
710
|
+
];
|
|
711
|
+
}
|
|
712
|
+
else {
|
|
713
|
+
out.files.push(['ldap/certs/ldap.crt', cert.crt], ['ldap/certs/ldap.key', cert.key], ['ldap/certs/ca.crt', cert.ca]);
|
|
714
|
+
}
|
|
715
|
+
if (pre.extra.directory_trust !== 'none') {
|
|
716
|
+
out.env.OVERWRITE_SETTING_LDAP_CA_Cert = cert.ca;
|
|
717
|
+
}
|
|
718
|
+
return out;
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* Group-to-role and group-to-channel sync: rocket-admin becomes `admin`, employee joins
|
|
722
|
+
* `#employees`. These settings exist only under an Enterprise licence with `ldap-enterprise`;
|
|
723
|
+
* without one Rocket.Chat never registers them and ignores the variables. Written in both
|
|
724
|
+
* spellings: 4.0.0 renamed `Groups*` to `Roles*`/`Channels*` and migrated the values, and an
|
|
725
|
+
* unregistered id is ignored, so the old one is harmless on a new release.
|
|
726
|
+
*/
|
|
727
|
+
function syncEnv(it) {
|
|
728
|
+
const groups = isAd(it) ? `OU=Groups,${it.baseDn}` : `ou=groups,${it.baseDn}`;
|
|
729
|
+
const filter = isAd(it)
|
|
730
|
+
? `(&(objectClass=group)(cn=#{groupName})(member:${IN_CHAIN}:=#{userdn}))`
|
|
731
|
+
: '(&(cn=#{groupName})(memberUid=#{username}))';
|
|
732
|
+
const roles = '{"rocket-admin":"admin"}';
|
|
733
|
+
const channels = '{"employee":"employees"}';
|
|
734
|
+
return {
|
|
735
|
+
OVERWRITE_SETTING_LDAP_Sync_User_Data_Roles: 'true',
|
|
736
|
+
OVERWRITE_SETTING_LDAP_Sync_User_Data_Roles_BaseDN: groups,
|
|
737
|
+
OVERWRITE_SETTING_LDAP_Sync_User_Data_Roles_Filter: filter,
|
|
738
|
+
OVERWRITE_SETTING_LDAP_Sync_User_Data_RolesMap: roles,
|
|
739
|
+
OVERWRITE_SETTING_LDAP_Sync_User_Data_Channels: 'true',
|
|
740
|
+
OVERWRITE_SETTING_LDAP_Sync_User_Data_Channels_BaseDN: groups,
|
|
741
|
+
OVERWRITE_SETTING_LDAP_Sync_User_Data_Channels_Filter: filter,
|
|
742
|
+
OVERWRITE_SETTING_LDAP_Sync_User_Data_ChannelsMap: channels,
|
|
743
|
+
// Before 4.0.0.
|
|
744
|
+
OVERWRITE_SETTING_LDAP_Sync_User_Data_Groups: 'true',
|
|
745
|
+
OVERWRITE_SETTING_LDAP_Sync_User_Data_Groups_BaseDN: groups,
|
|
746
|
+
OVERWRITE_SETTING_LDAP_Sync_User_Data_Groups_Filter: filter,
|
|
747
|
+
OVERWRITE_SETTING_LDAP_Sync_User_Data_GroupsMap: roles,
|
|
748
|
+
OVERWRITE_SETTING_LDAP_Sync_User_Data_Groups_AutoChannels: 'true',
|
|
749
|
+
OVERWRITE_SETTING_LDAP_Sync_User_Data_Groups_AutoChannelsMap: channels,
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
/** The directory's environment (osixia's names, which the image keeps), and the read-only user. */
|
|
753
|
+
function slapdEnv(it) {
|
|
754
|
+
return {
|
|
755
|
+
LDAP_ORGANISATION: 'Houston',
|
|
756
|
+
LDAP_DOMAIN: it.domain,
|
|
757
|
+
LDAP_BASE_DN: it.baseDn,
|
|
758
|
+
LDAP_ADMIN_PASSWORD: it.adminPassword,
|
|
759
|
+
...(it.bind === 'service'
|
|
760
|
+
? {
|
|
761
|
+
LDAP_READONLY_USER: 'true',
|
|
762
|
+
LDAP_READONLY_USER_USERNAME: READONLY_USER,
|
|
763
|
+
LDAP_READONLY_USER_PASSWORD: READONLY_PASSWORD,
|
|
764
|
+
}
|
|
765
|
+
: {}),
|
|
766
|
+
// houston's certificate instead of the image's self-signed one, and no client certificate
|
|
767
|
+
// asked for: the default `demand` refuses every Rocket.Chat connection.
|
|
768
|
+
...(it.tls === 'none'
|
|
769
|
+
? {}
|
|
770
|
+
: {
|
|
771
|
+
LDAP_TLS: 'true',
|
|
772
|
+
LDAP_TLS_CRT_FILENAME: 'ldap.crt',
|
|
773
|
+
LDAP_TLS_KEY_FILENAME: 'ldap.key',
|
|
774
|
+
LDAP_TLS_CA_CRT_FILENAME: 'ca.crt',
|
|
775
|
+
LDAP_TLS_VERIFY_CLIENT: 'never',
|
|
776
|
+
}),
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
/** The certificate files' Compose mounts, one file each, read in place (0644). */
|
|
780
|
+
function certVolumes(it) {
|
|
781
|
+
if (it.tls === 'none')
|
|
782
|
+
return [];
|
|
783
|
+
const dir = isAd(it) ? AD_CERTS_DIR : CERTS_DIR;
|
|
784
|
+
return CERT_FILES.map((file) => `./ldap/certs/${file}:${dir}/${file}:ro`);
|
|
785
|
+
}
|
|
786
|
+
/** What houston's create reads to issue the directory a certificate (`withCertificate`). */
|
|
787
|
+
function certificateExtra(it) {
|
|
788
|
+
if (it.tls === 'none')
|
|
789
|
+
return {};
|
|
790
|
+
return {
|
|
791
|
+
directory_tls: it.tls,
|
|
792
|
+
directory_trust: it.trust,
|
|
793
|
+
...(isAd(it) ? { directory_host: AD_HOST } : {}),
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
/** The AD flavour's Compose service. */
|
|
797
|
+
function adService(it) {
|
|
798
|
+
return {
|
|
799
|
+
image: AD_IMAGE,
|
|
800
|
+
entrypoint: ['/bin/sh', '-c', INSTALL_SEED_THEN_RUN],
|
|
801
|
+
environment: adEnv(it),
|
|
802
|
+
volumes: [`./ldap/ad-seed.sh:${AD_SEED_PATH}:ro`, ...certVolumes(it)],
|
|
803
|
+
restart: 'unless-stopped',
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
function describe(it) {
|
|
807
|
+
const sso = it.idp === 'none' ? '' : ` Keycloak signs the same users in by ${it.idp.toUpperCase()}.`;
|
|
808
|
+
return directoryDescription(it) + sso;
|
|
809
|
+
}
|
|
810
|
+
function directoryDescription(it) {
|
|
811
|
+
if (isAd(it)) {
|
|
812
|
+
return (`Samba as Active Directory seeded with ${String(it.users)} user(s) + group ` +
|
|
813
|
+
`'${GROUP_CN}'; RC wired for AD login. Log in as user1 / user1.`);
|
|
814
|
+
}
|
|
815
|
+
return (`OpenLDAP (v2.6.x) seeded with ${String(it.users)} user(s) + group ` +
|
|
816
|
+
`'${GROUP_CN}'; RC wired for LDAP login. Log in as user1 / user1.`);
|
|
817
|
+
}
|
|
818
|
+
function adNotes(it, uiPort) {
|
|
819
|
+
return [
|
|
820
|
+
// One string per point (see the SSO notes): the place with its login in parentheses, as
|
|
821
|
+
// the GUI's link rows read it, then prose.
|
|
822
|
+
`phpLDAPadmin: http://localhost:${String(uiPort)} (log in with DN CN=Administrator,CN=Users,${it.baseDn} / ${AD_ADMIN_PASSWORD})`,
|
|
823
|
+
`Rocket.Chat users are user1..user${String(it.users)} (sAMAccountName, or UPN userN@${it.domain}), password same as name; Rocket.Chat keys them by objectGUID.`,
|
|
824
|
+
...(it.users > exports.SHIPPED_USERS_MAX
|
|
825
|
+
? ['A large directory takes a while to seed: about 5 minutes for 20,000 users.']
|
|
826
|
+
: []),
|
|
827
|
+
...(it.groups
|
|
828
|
+
? [
|
|
829
|
+
`Groups: rocket-chat holds staff, which holds every user but the last; rocket-admin (user1); employee (everyone). Login asks for rocket-chat membership through the nesting (AD's in-chain rule), so user${String(it.users)} is refused. With an Enterprise license, rocket-admin members get the admin role and employee members join #employees at login.`,
|
|
830
|
+
'Samba returns every member of a large group at once; Windows AD splits one past 1,500 members into ranges, which this directory does not reproduce.',
|
|
831
|
+
]
|
|
832
|
+
: []),
|
|
833
|
+
...(it.bind === 'service'
|
|
834
|
+
? [
|
|
835
|
+
`Rocket.Chat binds as CN=${READONLY_USER},CN=Users,${it.baseDn} / ${READONLY_USER}, an ordinary user. Samba sets no page limit (Windows AD stops at 1,000 entries).`,
|
|
836
|
+
]
|
|
837
|
+
: []),
|
|
838
|
+
];
|
|
839
|
+
}
|
|
840
|
+
/** The scenario card's guide for this directory, its groups, its bind and its SSO. */
|
|
841
|
+
function guideFor(it) {
|
|
842
|
+
const n = String(it.users);
|
|
843
|
+
const ad = isAd(it);
|
|
844
|
+
const sso = it.idp !== 'none';
|
|
845
|
+
const saml = it.idp === 'saml';
|
|
846
|
+
const button = saml ? 'Keycloak SSO' : 'Keycloak (OIDC)';
|
|
847
|
+
const hostsEntry = sso && !saml && it.idpHost === 'keycloak';
|
|
848
|
+
return (0, guides_1.guide)('ldap', {
|
|
849
|
+
summary: ad
|
|
850
|
+
? `Samba as Active Directory with ${n} users${it.groups ? ' and nested groups' : ''}; Rocket.Chat signs them in.`
|
|
851
|
+
: `OpenLDAP with ${n} users and the group rc-users; Rocket.Chat signs them in.`,
|
|
852
|
+
setup: hostsEntry
|
|
853
|
+
? {
|
|
854
|
+
why: keycloak.HOSTS_ENTRY_WHY,
|
|
855
|
+
line: '127.0.0.1 keycloak',
|
|
856
|
+
}
|
|
857
|
+
: null,
|
|
858
|
+
signIn: [
|
|
859
|
+
[`user1 … user${n}`, 'same as the name', 'Rocket.Chat, LDAP login'],
|
|
860
|
+
[...adminLogin(it), 'phpLDAPadmin, as a DN'],
|
|
861
|
+
...(sso
|
|
862
|
+
? [
|
|
863
|
+
[`user1 … user${n}`, 'same as the name', `press '${button}' on the login page`],
|
|
864
|
+
['admin', 'admin', `Keycloak admin console, realm '${keycloak.REALM}'`],
|
|
865
|
+
]
|
|
866
|
+
: []),
|
|
867
|
+
],
|
|
868
|
+
steps: [
|
|
869
|
+
'Sign in to Rocket.Chat as user1 / user1.',
|
|
870
|
+
'Browse the directory in phpLDAPadmin with the admin DN.',
|
|
871
|
+
sso
|
|
872
|
+
? `Or press '${button}' and sign in as user1 / user1: Keycloak signs in the same directory user.`
|
|
873
|
+
: '',
|
|
874
|
+
],
|
|
875
|
+
know: [
|
|
876
|
+
...(it.groups
|
|
877
|
+
? ad
|
|
878
|
+
? [
|
|
879
|
+
`rocket-chat holds staff (every user but the last); rocket-admin holds user1; employee holds everyone. Login asks for rocket-chat membership through the nesting (AD's in-chain rule), so user${n} is refused.`,
|
|
880
|
+
'With an Enterprise license rocket-admin members get the admin role and employee members join #employees at login.',
|
|
881
|
+
'Samba returns every member of a large group at once; Windows AD splits one past 1,500 members into ranges, which this directory does not reproduce.',
|
|
882
|
+
]
|
|
883
|
+
: [
|
|
884
|
+
`Groups: rocket-chat (all but the last user), rocket-admin (user1), employee (all). Only rocket-chat may log in: user${n} is refused by the group filter.`,
|
|
885
|
+
'With an Enterprise license (--license, or the Enterprise license field when creating; or a registration token), rocket-admin members get the admin role and employee members join #employees at login.',
|
|
886
|
+
]
|
|
887
|
+
: []),
|
|
888
|
+
it.bind === 'service'
|
|
889
|
+
? ad
|
|
890
|
+
? `Rocket.Chat binds as CN=${READONLY_USER},CN=Users,${it.baseDn} / ${READONLY_USER}, an ordinary user. Samba sets no page limit (Windows AD stops at 1,000 entries).`
|
|
891
|
+
: `Rocket.Chat binds as cn=${READONLY_USER},${it.baseDn} / ${READONLY_PASSWORD}; slapd limits it to 500 entries per search, so a sync over more users hits it.`
|
|
892
|
+
: '',
|
|
893
|
+
it.users > exports.SHIPPED_USERS_MAX
|
|
894
|
+
? 'A large directory takes a while to seed: about 5 minutes for 20,000 users.'
|
|
895
|
+
: '',
|
|
896
|
+
sso
|
|
897
|
+
? 'Rocket.Chat matches the Keycloak sign-in to the directory user by email; the Keycloak users are under User federation > directory.'
|
|
898
|
+
: '',
|
|
899
|
+
sso && it.mfa
|
|
900
|
+
? 'Keycloak asks each user to set up an authenticator app at the first sign-in.'
|
|
901
|
+
: '',
|
|
902
|
+
hostsEntry
|
|
903
|
+
? `The hosts entry works only for a browser on the machine running houston. ${keycloak.FROM_ANOTHER_COMPUTER}`
|
|
904
|
+
: sso && it.idpHost === 'localhost'
|
|
905
|
+
? `Keycloak is reached on localhost, so the browser must be on the machine running houston. ${keycloak.FROM_ANOTHER_COMPUTER}`
|
|
906
|
+
: '',
|
|
907
|
+
],
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
function notesFor(it, uiPort) {
|
|
911
|
+
if (isAd(it))
|
|
912
|
+
return adNotes(it, uiPort);
|
|
913
|
+
return [
|
|
914
|
+
`phpLDAPadmin: http://localhost:${String(uiPort)} (log in with DN cn=admin,${it.baseDn} / ${it.adminPassword})`,
|
|
915
|
+
`Rocket.Chat users are user1..user${String(it.users)}, password same as name.`,
|
|
916
|
+
...(it.groups
|
|
917
|
+
? [
|
|
918
|
+
`Groups: rocket-chat (all but the last user), rocket-admin (user1), employee (all). Only rocket-chat may log in: user${String(it.users)} is refused by the group filter. With an Enterprise license (--license, or the Enterprise license field when creating; or a registration token), rocket-admin members get the admin role and employee members join #employees at login.`,
|
|
919
|
+
]
|
|
920
|
+
: []),
|
|
921
|
+
...(it.bind === 'service'
|
|
922
|
+
? [
|
|
923
|
+
`Rocket.Chat binds as cn=${READONLY_USER},${it.baseDn} / ${READONLY_PASSWORD}, whom slapd limits to 500 entries per search: a sync over more users hits it.`,
|
|
924
|
+
]
|
|
925
|
+
: []),
|
|
926
|
+
];
|
|
927
|
+
}
|
|
928
|
+
function openldapService(it) {
|
|
929
|
+
return generated(it)
|
|
930
|
+
? {
|
|
931
|
+
image: DIRECTORY_IMAGE,
|
|
932
|
+
entrypoint: ['/bin/sh', '-c', GENERATE_THEN_RUN],
|
|
933
|
+
environment: { ...slapdEnv(it), ...generatorEnv(it) },
|
|
934
|
+
volumes: [`./ldap/gen-users.sh:${GENERATOR_PATH}:ro`, ...certVolumes(it)],
|
|
935
|
+
restart: 'unless-stopped',
|
|
936
|
+
}
|
|
937
|
+
: {
|
|
938
|
+
image: DIRECTORY_IMAGE,
|
|
939
|
+
environment: slapdEnv(it),
|
|
940
|
+
volumes: [`./ldap/50-rc-users.ldif:${BOOTSTRAP_PATH}:ro`, ...certVolumes(it)],
|
|
941
|
+
restart: 'unless-stopped',
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
function composeAdapter(it, ports) {
|
|
945
|
+
const host = hostOf(it);
|
|
946
|
+
const uiPort = uiPortOf(ports);
|
|
947
|
+
const idp = idpParts(it, ports);
|
|
948
|
+
const services = {
|
|
949
|
+
[host]: isAd(it) ? adService(it) : openldapService(it),
|
|
950
|
+
// A directory you cannot look at is hard to reproduce against: "is the user there,
|
|
951
|
+
// and what attributes does it have" is the first question of nearly every LDAP
|
|
952
|
+
// ticket, and answering it meant `docker exec ... ldapsearch`.
|
|
953
|
+
// Plain HTTP: the directory is on a private network with a fixed throwaway password, and
|
|
954
|
+
// an HTTPS workspace serves it through its own name instead (`withPublicUrl`).
|
|
955
|
+
phpldapadmin: {
|
|
956
|
+
image: UI_IMAGE,
|
|
957
|
+
environment: uiEnv(it),
|
|
958
|
+
ports: [`${String(uiPort)}:${String(exports.UI_CONTAINER_PORT)}`],
|
|
959
|
+
depends_on: [host],
|
|
960
|
+
restart: 'unless-stopped',
|
|
961
|
+
},
|
|
962
|
+
...(idp === null
|
|
963
|
+
? {}
|
|
964
|
+
: {
|
|
965
|
+
keycloak: keycloak.service('./ldap/keycloak-realm.json', idp.port, it.idp === 'oidc' ? idp.port : undefined),
|
|
966
|
+
}),
|
|
967
|
+
};
|
|
968
|
+
return {
|
|
969
|
+
...(0, types_1.emptyPreset)('ldap'),
|
|
970
|
+
description: describe(it),
|
|
971
|
+
env: { ...envFor(it), ...idp?.env },
|
|
972
|
+
softEnv: [common_1.EMAIL_2FA],
|
|
973
|
+
services,
|
|
974
|
+
dependsOn: idp === null ? [host] : [host, 'keycloak'],
|
|
975
|
+
requiresLicense: false,
|
|
976
|
+
source: 'built-in (dynamic)',
|
|
977
|
+
files: [
|
|
978
|
+
...directoryFiles(it),
|
|
979
|
+
...(idp === null ? [] : [['ldap/keycloak-realm.json', idp.realm]]),
|
|
980
|
+
],
|
|
981
|
+
// Declared so port allocation and the capacity preflight can SEE it --
|
|
982
|
+
// the invariant that holds each preset's ports to the registry caught this being
|
|
983
|
+
// missing the moment phpLDAPadmin gained a port.
|
|
984
|
+
ports: [uiPort, ...(idp === null ? [] : [idp.port])],
|
|
985
|
+
notes: [...notesFor(it, uiPort), ...(idp?.notes ?? [])],
|
|
986
|
+
guides: [guideFor(it)],
|
|
987
|
+
postReady: idp?.postReady ?? [],
|
|
988
|
+
paramsHelp: { ...PARAMS_HELP },
|
|
989
|
+
scenario: 'ldap',
|
|
990
|
+
scenarioParams: asParams(it),
|
|
991
|
+
extra: certificateExtra(it),
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
/** What the directory is seeded from: the AD seed, the generator, or the LDIF itself. */
|
|
995
|
+
function directoryFiles(it) {
|
|
996
|
+
if (isAd(it))
|
|
997
|
+
return [['ldap/ad-seed.sh', exports.AD_SEED]];
|
|
998
|
+
return generated(it) ? [['ldap/gen-users.sh', exports.GENERATOR]] : [['ldap/50-rc-users.ldif', ldif(it)]];
|
|
999
|
+
}
|
|
1000
|
+
/** The phpLDAPadmin browser UI, which is the only way to see what LDAP holds. */
|
|
1001
|
+
function phpldapadminWorkload(labels, it, uiPort) {
|
|
1002
|
+
// phpLDAPadmin, and the label that gets it published. A Service carrying
|
|
1003
|
+
// `houston.io/ui-port` is forwarded to that host port by the Kubernetes lifecycle -- the
|
|
1004
|
+
// declaration lives on the Service that defines the thing, rather than in a second
|
|
1005
|
+
// registry the adapter would have to be kept in step with. The NUMBER is the workspace's
|
|
1006
|
+
// ldap port, so both runtimes publish the same one.
|
|
1007
|
+
const uiLabels = { ...labels };
|
|
1008
|
+
uiLabels.app = 'houston-phpldapadmin';
|
|
1009
|
+
uiLabels[exports.UI_PORT_LABEL] = String(uiPort);
|
|
1010
|
+
const uiDeployment = {
|
|
1011
|
+
apiVersion: 'apps/v1',
|
|
1012
|
+
kind: 'Deployment',
|
|
1013
|
+
metadata: { name: 'phpldapadmin', labels: uiLabels },
|
|
1014
|
+
spec: {
|
|
1015
|
+
replicas: 1,
|
|
1016
|
+
selector: { matchLabels: { app: uiLabels.app } },
|
|
1017
|
+
template: {
|
|
1018
|
+
metadata: { labels: uiLabels },
|
|
1019
|
+
spec: {
|
|
1020
|
+
containers: [
|
|
1021
|
+
{
|
|
1022
|
+
name: 'phpldapadmin',
|
|
1023
|
+
image: UI_IMAGE,
|
|
1024
|
+
env: Object.entries(uiEnv(it)).map(([name, value]) => ({ name, value })),
|
|
1025
|
+
ports: [{ containerPort: exports.UI_CONTAINER_PORT }],
|
|
1026
|
+
// Laravel's own health route: `/` answers a redirect to the sign-in page.
|
|
1027
|
+
readinessProbe: {
|
|
1028
|
+
httpGet: { path: '/up', port: exports.UI_CONTAINER_PORT },
|
|
1029
|
+
initialDelaySeconds: 3,
|
|
1030
|
+
periodSeconds: 3,
|
|
1031
|
+
failureThreshold: 30,
|
|
1032
|
+
},
|
|
1033
|
+
},
|
|
1034
|
+
],
|
|
1035
|
+
},
|
|
1036
|
+
},
|
|
1037
|
+
},
|
|
1038
|
+
};
|
|
1039
|
+
const uiService = {
|
|
1040
|
+
apiVersion: 'v1',
|
|
1041
|
+
kind: 'Service',
|
|
1042
|
+
metadata: { name: 'phpldapadmin', labels: uiLabels },
|
|
1043
|
+
spec: {
|
|
1044
|
+
selector: { app: uiLabels.app },
|
|
1045
|
+
// The forward to the host port reads `targetPort`; an Ingress reaches the Service's 80.
|
|
1046
|
+
ports: [{ name: 'http', port: 80, targetPort: exports.UI_CONTAINER_PORT }],
|
|
1047
|
+
},
|
|
1048
|
+
};
|
|
1049
|
+
return [uiDeployment, uiService];
|
|
1050
|
+
}
|
|
1051
|
+
/** The OpenLDAP Deployment and the Service in front of it. */
|
|
1052
|
+
function openldapWorkload(it, labels) {
|
|
1053
|
+
const deployment = {
|
|
1054
|
+
apiVersion: 'apps/v1',
|
|
1055
|
+
kind: 'Deployment',
|
|
1056
|
+
metadata: { name: 'openldap', labels },
|
|
1057
|
+
spec: {
|
|
1058
|
+
replicas: 1,
|
|
1059
|
+
selector: { matchLabels: { app: labels.app } },
|
|
1060
|
+
template: {
|
|
1061
|
+
metadata: { labels },
|
|
1062
|
+
spec: {
|
|
1063
|
+
containers: [
|
|
1064
|
+
{
|
|
1065
|
+
name: 'openldap',
|
|
1066
|
+
image: DIRECTORY_IMAGE,
|
|
1067
|
+
...(generated(it) ? { command: ['/bin/sh', '-c', GENERATE_THEN_RUN] } : {}),
|
|
1068
|
+
env: Object.entries({
|
|
1069
|
+
...slapdEnv(it),
|
|
1070
|
+
...(generated(it) ? generatorEnv(it) : {}),
|
|
1071
|
+
}).map(([name, value]) => ({ name, value })),
|
|
1072
|
+
ports: [
|
|
1073
|
+
{ name: 'ldap', containerPort: 389 },
|
|
1074
|
+
...(it.tls === 'ldaps' ? [{ name: 'ldaps', containerPort: 636 }] : []),
|
|
1075
|
+
],
|
|
1076
|
+
// slapd binds 389 only after the bootstrap LDIF is imported, and without
|
|
1077
|
+
// this the pod is Ready the instant the container starts -- so the Service
|
|
1078
|
+
// publishes an endpoint that is not serving, and Rocket.Chat starts against
|
|
1079
|
+
// an LDAP that is not answering. That is a first-login failure nobody would
|
|
1080
|
+
// connect back to here. tcpSocket rather than httpGet: LDAP is not HTTP,
|
|
1081
|
+
// and slapd binding the port IS the milestone.
|
|
1082
|
+
readinessProbe: {
|
|
1083
|
+
tcpSocket: { port: 389 },
|
|
1084
|
+
initialDelaySeconds: 5,
|
|
1085
|
+
periodSeconds: 3,
|
|
1086
|
+
failureThreshold: 40,
|
|
1087
|
+
},
|
|
1088
|
+
volumeMounts: [
|
|
1089
|
+
generated(it)
|
|
1090
|
+
? { name: 'bootstrap', mountPath: GENERATOR_PATH, subPath: 'gen-users.sh' }
|
|
1091
|
+
: { name: 'bootstrap', mountPath: BOOTSTRAP_PATH, subPath: '50-rc-users.ldif' },
|
|
1092
|
+
...(it.tls === 'none'
|
|
1093
|
+
? []
|
|
1094
|
+
: CERT_FILES.map((file) => ({
|
|
1095
|
+
name: 'tls',
|
|
1096
|
+
mountPath: `${CERTS_DIR}/${file}`,
|
|
1097
|
+
subPath: file,
|
|
1098
|
+
}))),
|
|
1099
|
+
],
|
|
1100
|
+
},
|
|
1101
|
+
],
|
|
1102
|
+
volumes: [
|
|
1103
|
+
{ name: 'bootstrap', configMap: { name: 'openldap-bootstrap' } },
|
|
1104
|
+
...(it.tls === 'none' ? [] : [{ name: 'tls', secret: { secretName: TLS_SECRET } }]),
|
|
1105
|
+
],
|
|
1106
|
+
},
|
|
1107
|
+
},
|
|
1108
|
+
},
|
|
1109
|
+
};
|
|
1110
|
+
const service = {
|
|
1111
|
+
apiVersion: 'v1',
|
|
1112
|
+
kind: 'Service',
|
|
1113
|
+
metadata: { name: 'openldap', labels },
|
|
1114
|
+
spec: {
|
|
1115
|
+
selector: { app: labels.app },
|
|
1116
|
+
// 636 too for LDAPS: slapd serves it, and without it here Rocket.Chat's connection to
|
|
1117
|
+
// openldap:636 timed out (measured on k3s) while 389 answered.
|
|
1118
|
+
ports: [
|
|
1119
|
+
{ name: 'ldap', port: 389, targetPort: 389 },
|
|
1120
|
+
...(it.tls === 'ldaps' ? [{ name: 'ldaps', port: 636, targetPort: 636 }] : []),
|
|
1121
|
+
],
|
|
1122
|
+
},
|
|
1123
|
+
};
|
|
1124
|
+
return [deployment, service];
|
|
1125
|
+
}
|
|
1126
|
+
/** The AD flavour's Deployment and Service: the same seed as Compose, from a ConfigMap. */
|
|
1127
|
+
function adWorkload(it, labels) {
|
|
1128
|
+
const tlsMounts = it.tls === 'none'
|
|
1129
|
+
? []
|
|
1130
|
+
: CERT_FILES.map((file) => ({
|
|
1131
|
+
name: 'tls',
|
|
1132
|
+
mountPath: `${AD_CERTS_DIR}/${file}`,
|
|
1133
|
+
subPath: file,
|
|
1134
|
+
}));
|
|
1135
|
+
const deployment = {
|
|
1136
|
+
apiVersion: 'apps/v1',
|
|
1137
|
+
kind: 'Deployment',
|
|
1138
|
+
metadata: { name: AD_HOST, labels },
|
|
1139
|
+
spec: {
|
|
1140
|
+
replicas: 1,
|
|
1141
|
+
selector: { matchLabels: { app: labels.app } },
|
|
1142
|
+
template: {
|
|
1143
|
+
metadata: { labels },
|
|
1144
|
+
spec: {
|
|
1145
|
+
containers: [
|
|
1146
|
+
{
|
|
1147
|
+
name: AD_HOST,
|
|
1148
|
+
image: AD_IMAGE,
|
|
1149
|
+
command: ['/bin/sh', '-c', INSTALL_SEED_THEN_RUN],
|
|
1150
|
+
env: Object.entries(adEnv(it)).map(([name, value]) => ({ name, value })),
|
|
1151
|
+
ports: [
|
|
1152
|
+
{ name: 'ldap', containerPort: 389 },
|
|
1153
|
+
...(it.tls === 'ldaps' ? [{ name: 'ldaps', containerPort: 636 }] : []),
|
|
1154
|
+
],
|
|
1155
|
+
// samba binds 389 only once the seed is in, so Ready means the users are there.
|
|
1156
|
+
readinessProbe: {
|
|
1157
|
+
tcpSocket: { port: 389 },
|
|
1158
|
+
initialDelaySeconds: 5,
|
|
1159
|
+
periodSeconds: 3,
|
|
1160
|
+
failureThreshold: 40,
|
|
1161
|
+
},
|
|
1162
|
+
volumeMounts: [
|
|
1163
|
+
{ name: 'seed', mountPath: AD_SEED_PATH, subPath: 'ad-seed.sh' },
|
|
1164
|
+
...tlsMounts,
|
|
1165
|
+
],
|
|
1166
|
+
},
|
|
1167
|
+
],
|
|
1168
|
+
volumes: [
|
|
1169
|
+
{ name: 'seed', configMap: { name: `${AD_HOST}-seed` } },
|
|
1170
|
+
...(it.tls === 'none' ? [] : [{ name: 'tls', secret: { secretName: TLS_SECRET } }]),
|
|
1171
|
+
],
|
|
1172
|
+
},
|
|
1173
|
+
},
|
|
1174
|
+
},
|
|
1175
|
+
};
|
|
1176
|
+
const service = {
|
|
1177
|
+
apiVersion: 'v1',
|
|
1178
|
+
kind: 'Service',
|
|
1179
|
+
metadata: { name: AD_HOST, labels },
|
|
1180
|
+
spec: {
|
|
1181
|
+
selector: { app: labels.app },
|
|
1182
|
+
ports: [
|
|
1183
|
+
{ name: 'ldap', port: 389, targetPort: 389 },
|
|
1184
|
+
...(it.tls === 'ldaps' ? [{ name: 'ldaps', port: 636, targetPort: 636 }] : []),
|
|
1185
|
+
],
|
|
1186
|
+
},
|
|
1187
|
+
};
|
|
1188
|
+
return [deployment, service];
|
|
1189
|
+
}
|
|
1190
|
+
/** The seed ConfigMap's data: the directory files under their own names. */
|
|
1191
|
+
function seedData(it) {
|
|
1192
|
+
return Object.fromEntries(directoryFiles(it).map(([file, text]) => [file.slice('ldap/'.length), text]));
|
|
1193
|
+
}
|
|
1194
|
+
/** Render the small directory workload used by the Kubernetes adapter. */
|
|
1195
|
+
function kubernetesManifest(it, uiPort) {
|
|
1196
|
+
const labels = {
|
|
1197
|
+
app: isAd(it) ? `houston-${AD_HOST}` : 'houston-openldap',
|
|
1198
|
+
'app.kubernetes.io/managed-by': 'houston',
|
|
1199
|
+
'houston.io/component': 'ldap',
|
|
1200
|
+
// The Kubernetes lifecycle substitutes the namespace-local repro name.
|
|
1201
|
+
'houston.io/repro': '__HOUSTON_NAME__',
|
|
1202
|
+
};
|
|
1203
|
+
const configMap = {
|
|
1204
|
+
apiVersion: 'v1',
|
|
1205
|
+
kind: 'ConfigMap',
|
|
1206
|
+
metadata: { name: isAd(it) ? `${AD_HOST}-seed` : 'openldap-bootstrap', labels },
|
|
1207
|
+
data: seedData(it),
|
|
1208
|
+
};
|
|
1209
|
+
const [deployment, service] = isAd(it) ? adWorkload(it, labels) : openldapWorkload(it, labels);
|
|
1210
|
+
// A CHANGED SEED ROLLS THE DIRECTORY. slapd keeps its entries in the pod and reads the seed
|
|
1211
|
+
// once; a ConfigMap edit restarts nothing, so a re-up with `--set users=9` recorded 9 and
|
|
1212
|
+
// kept serving 5 (live 2026-10-31). Stamped only off the default seed: a default workspace,
|
|
1213
|
+
// and the manifests earlier releases pin, are unchanged, and a re-up of either rolls nothing.
|
|
1214
|
+
// Only an LDIF seed: AD's and the generator's are fixed scripts whose counts ride in the env,
|
|
1215
|
+
// which rolls the pod already -- a stamp there would only roll a 2.1.6 workspace once, and
|
|
1216
|
+
// a re-provisioned AD gives every user a new objectGUID, which Rocket.Chat matches them by.
|
|
1217
|
+
const seed = JSON.stringify(configMap.data);
|
|
1218
|
+
if (!isAd(it) && !generated(it) && seed !== JSON.stringify(seedData(intent({})))) {
|
|
1219
|
+
const template = deployment.spec.template;
|
|
1220
|
+
template.metadata = {
|
|
1221
|
+
...template.metadata,
|
|
1222
|
+
annotations: {
|
|
1223
|
+
'houston.io/seed': (0, node_crypto_1.createHash)('sha256').update(seed).digest('hex').slice(0, 16),
|
|
1224
|
+
},
|
|
1225
|
+
};
|
|
1226
|
+
}
|
|
1227
|
+
const [uiDeployment, uiService] = phpldapadminWorkload(labels, it, uiPort);
|
|
1228
|
+
return [configMap, deployment, service, uiDeployment, uiService]
|
|
1229
|
+
.map((doc) => (0, common_1.safeDump)(doc))
|
|
1230
|
+
.join('---\n');
|
|
1231
|
+
}
|
|
1232
|
+
function kubernetesAdapter(it, ports) {
|
|
1233
|
+
const uiPort = uiPortOf(ports);
|
|
1234
|
+
const idp = idpParts(it, ports);
|
|
1235
|
+
return {
|
|
1236
|
+
...(0, types_1.emptyPreset)('ldap'),
|
|
1237
|
+
description: describe(it),
|
|
1238
|
+
notes: [...notesFor(it, uiPort), ...(idp?.notes ?? [])],
|
|
1239
|
+
guides: [guideFor(it)],
|
|
1240
|
+
postReady: idp?.postReady ?? [],
|
|
1241
|
+
topology: 'kubernetes',
|
|
1242
|
+
// Declared here for the same reason the Compose adapter declares it: phpLDAPadmin is
|
|
1243
|
+
// published on the workspace's host port on this runtime too (as a port-forward rather
|
|
1244
|
+
// than a compose mapping). The Kubernetes create allocates it as Compose does
|
|
1245
|
+
// (`lifecycle/ports.ts` `claimSidePorts`) and records it as `sidecar_ports`. Until that
|
|
1246
|
+
// step existed this list was read by nothing here, and a second workspace's forward
|
|
1247
|
+
// simply failed to bind 8082.
|
|
1248
|
+
ports: [uiPort, ...(idp === null ? [] : [idp.port])],
|
|
1249
|
+
// The scenario changes the backing service and Rocket.Chat settings; it does not make
|
|
1250
|
+
// the microservices deployment cease to be an Enterprise topology. Preserve that
|
|
1251
|
+
// deployment-level requirement so lifecycle warnings and onboarding next-command
|
|
1252
|
+
// guidance remain truthful.
|
|
1253
|
+
requiresLicense: true,
|
|
1254
|
+
source: 'built-in (scenario)',
|
|
1255
|
+
env: { ...envFor(it), ...idp?.env },
|
|
1256
|
+
softEnv: [common_1.EMAIL_2FA],
|
|
1257
|
+
paramsHelp: { ...PARAMS_HELP },
|
|
1258
|
+
scenario: 'ldap',
|
|
1259
|
+
scenarioParams: asParams(it),
|
|
1260
|
+
extra: certificateExtra(it),
|
|
1261
|
+
kubernetesManifests: [
|
|
1262
|
+
kubernetesManifest(it, uiPort),
|
|
1263
|
+
...(idp === null
|
|
1264
|
+
? []
|
|
1265
|
+
: [keycloak.manifests(idp.realm, idp.port, it.idp === 'oidc' ? idp.port : undefined)]),
|
|
1266
|
+
],
|
|
1267
|
+
};
|
|
1268
|
+
}
|
|
1269
|
+
const SCENARIO = new scenario_1.Scenario({
|
|
1270
|
+
name: 'ldap',
|
|
1271
|
+
paramsHelp: PARAMS_HELP,
|
|
1272
|
+
resolveIntent: intent,
|
|
1273
|
+
// Keyed by RUNTIME, in `core/topology.ts`'s words. See the note on `Preset.topology`
|
|
1274
|
+
// for why there is only one set of words for this.
|
|
1275
|
+
adapters: { docker: composeAdapter, kubernetes: kubernetesAdapter },
|
|
1276
|
+
});
|
|
1277
|
+
function scenario() {
|
|
1278
|
+
return SCENARIO;
|
|
1279
|
+
}
|
|
1280
|
+
/** Legacy `ldap` loader entry point; resolve through the Compose adapter. */
|
|
1281
|
+
function build(params, ports) {
|
|
1282
|
+
return SCENARIO.resolve(params, 'docker', ports);
|
|
1283
|
+
}
|
|
1284
|
+
(0, registry_1.register)('ldap', build);
|
|
1285
|
+
(0, registry_1.registerScenario)('ldap', SCENARIO);
|