@nasebanal/cli 0.14.0 → 0.15.0

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/README.md CHANGED
@@ -639,6 +639,34 @@ Overridable env vars: `NB_AUTH0_DOMAIN`, `NB_AUTH0_AUDIENCE`,
639
639
  The active environment defaults to `production`; `--env local` targets the
640
640
  `wrangler dev` servers declared in each spec.
641
641
 
642
+ ## Other NASEBANAL tools (`nb secrets`, `nb quickstarts`)
643
+
644
+ `nb <name> ...` runs the program `nb-<name>` found on your `PATH`, the way `git` and `kubectl` run their extensions. NASEBANAL's other tools keep their own repositories, install and releases, and do not need Node or this package; `nb` only finds them and hands over.
645
+
646
+ ```bash
647
+ # install a tool once, from its own repository (each has a `--install` that links it into ~/.local/bin)
648
+ git clone https://github.com/nasebanal/nb-secrets.git && nb-secrets/bin/nb-secrets --install
649
+
650
+ nb secrets list ~/.secrets/deploy.env.age # = nb-secrets list ...
651
+ nb secrets -h # the tool's own usage
652
+ nb -h # lists the installed tools, and where to get the ones that are not
653
+ ```
654
+
655
+ | Tool | What it is |
656
+ |---|---|
657
+ | [`nb-secrets`](https://github.com/nasebanal/nb-secrets) | Secrets in passphrase-encrypted files, handed to a command only when you type the passphrase |
658
+ | [`nb-quickstarts`](https://github.com/nasebanal/nb-quickstarts) | Docker and Makefile quickstarts for infrastructure and testing tools |
659
+
660
+ How it behaves:
661
+
662
+ - **A built-in command always wins.** A program called `nb-auth` on `PATH` cannot take over `nb auth`; the generated API groups are protected the same way. Only the first word after `nb` is looked at (`nb secrets ...`, not `nb --env local secrets ...`).
663
+ - **Nothing is run to build the list.** `nb -h` must stay fast and must not execute whatever is called `nb-*` on your `PATH`, so a tool's one-line description is **read** from the first comment line after its shebang: `# nb-<name> - <what it does>`. A program that is not a script is listed by name only.
664
+ - **A tool is started only when you type its name**, directly (never through a shell), with your terminal, environment and exit status passed through, and `NB_PLUGIN_NAME="nb <name>"` set so it can print its usage the way it was called. Ctrl-C is left to the tool (a passphrase prompt, for example).
665
+ - **A published tool that is not installed** gets a message with its repository instead of "unknown command".
666
+ - Names are plain lowercase (`[a-z][a-z0-9-]*`); the first match on `PATH` wins; macOS and Linux only. Anything named `nb-<name>` and executable on your `PATH` runs with your rights, as with any command, so keep `PATH` to directories you trust.
667
+
668
+ To make your own: an executable `nb-<name>` on `PATH` whose second line is `# nb-<name> - <one line>`.
669
+
642
670
  ## Adding a New API
643
671
 
644
672
  1. Publish/own its spec in `nb-api-specs` (it ships as `@nasebanal/api-specs-<api>`).
package/dist/index.js CHANGED
@@ -17,6 +17,7 @@ import { buildReportUploadCommand } from "./reports/upload.js";
17
17
  import { attachMonitorSpecOptions } from "./reports/monitors.js";
18
18
  import { attachSpecsCommands, buildSpecsCommand } from "./specs/command.js";
19
19
  import { buildUpgradeCommand, startUpdateNotifier } from "./update.js";
20
+ import { findPlugins, missingMessage, pluginCall, pluginHelp, runPlugin } from "./plugins.js";
20
21
  // Single source of truth for the version: package.json (dist/ and src/ both sit
21
22
  // next to it). A hard-coded string here drifts from the release tag.
22
23
  const { version } = createRequire(import.meta.url)("../package.json");
@@ -62,7 +63,22 @@ for (const api of API_CATALOG) {
62
63
  attachSpecsCommands(group);
63
64
  program.addCommand(group);
64
65
  }
66
+ // External tools (`nb secrets` runs `nb-secrets` from PATH). A built-in command, a generated API group included, always
67
+ // wins over a tool of the same name; `nb -h` lists what is installed (read from the scripts, nothing is run).
68
+ const reserved = new Set(["help", ...program.commands.flatMap((c) => [c.name(), ...c.aliases()])]);
69
+ program.addHelpText("after", () => pluginHelp(findPlugins(process.env.PATH, reserved)));
65
70
  async function main() {
71
+ const call = pluginCall(process.argv, process.env.PATH, reserved);
72
+ if (call) {
73
+ if ("missing" in call) {
74
+ process.stderr.write(`${missingMessage(call.missing)}\n`);
75
+ process.exitCode = 1;
76
+ }
77
+ else {
78
+ process.exitCode = await runPlugin(call.plugin, call.args);
79
+ }
80
+ return;
81
+ }
66
82
  const notifier = startUpdateNotifier(version, process.argv);
67
83
  try {
68
84
  await program.parseAsync(process.argv);
@@ -0,0 +1,176 @@
1
+ /**
2
+ * External tools: `nb <name> ...` runs the program `nb-<name>` found on PATH, the way `git` and `kubectl` do.
3
+ *
4
+ * Independent NASEBANAL tools (`nb-secrets`, `nb-quickstarts`) keep their own repositories, their own install and
5
+ * their own release; they do not need Node or this package. `nb` only finds them and hands over, so `nb secrets -h`
6
+ * shows the tool's own usage, and `nb -h` lists what is installed.
7
+ *
8
+ * Decisions that matter:
9
+ * - A built-in command always wins over a tool of the same name, so a tool cannot take over `nb auth`.
10
+ * - Nothing is executed to build the list (`nb -h` must be fast and must not run whatever happens to be called `nb-*`
11
+ * on PATH): the one-line description is READ from the first comment line of the script, `# nb-<name> - <what it does>`.
12
+ * A program that is not a script has a name and no description.
13
+ * - The program is started directly, never through a shell, and only when the user types its name.
14
+ * - macOS and Linux (executable bit, `:` in PATH). On Windows no tool is found.
15
+ */
16
+ import { spawn } from "node:child_process";
17
+ import { accessSync, closeSync, constants, openSync, readdirSync, readSync, statSync } from "node:fs";
18
+ import { delimiter, join } from "node:path";
19
+ import { constants as osConstants } from "node:os";
20
+ /** Tools NASEBANAL publishes, so `nb -h` and a mistyped call can say where to get one that is not installed. */
21
+ export const KNOWN_TOOLS = {
22
+ secrets: { repo: "https://github.com/nasebanal/nb-secrets" },
23
+ quickstarts: { repo: "https://github.com/nasebanal/nb-quickstarts" },
24
+ };
25
+ const NAME = /^[a-z][a-z0-9-]{0,30}$/;
26
+ const DESCRIPTION_MAX = 100;
27
+ /** Whether `name` could be a tool name: plain lowercase, so nothing like `../x` ever reaches the file system. */
28
+ export function isPluginName(name) {
29
+ return NAME.test(name);
30
+ }
31
+ /** The one-line description in the first comment line after the shebang (`# nb-secrets - keep secrets ...`), or "". */
32
+ export function describePlugin(file, name) {
33
+ let head = "";
34
+ try {
35
+ const fd = openSync(file, "r");
36
+ try {
37
+ const buf = Buffer.alloc(2048);
38
+ const n = readSync(fd, buf, 0, buf.length, 0);
39
+ head = buf.subarray(0, n).toString("utf8");
40
+ }
41
+ finally {
42
+ closeSync(fd);
43
+ }
44
+ }
45
+ catch {
46
+ return "";
47
+ }
48
+ if (!head.startsWith("#!"))
49
+ return ""; // a binary (or anything that is not a script) gives no description
50
+ for (const line of head.split("\n").slice(1)) {
51
+ if (!line.startsWith("#"))
52
+ return "";
53
+ const text = line.replace(/^#\s?/, "").trim();
54
+ if (text === "")
55
+ continue;
56
+ const m = /^nb-([a-z0-9-]+)\s+-\s+(.+)$/.exec(text);
57
+ // The first non-empty comment line is the description, or there is none: do not dig for one.
58
+ return m && m[1] === name ? m[2].slice(0, DESCRIPTION_MAX) : "";
59
+ }
60
+ return "";
61
+ }
62
+ function isExecutableFile(file) {
63
+ try {
64
+ if (!statSync(file).isFile())
65
+ return false; // follows a symlink
66
+ accessSync(file, constants.X_OK);
67
+ return true;
68
+ }
69
+ catch {
70
+ return false;
71
+ }
72
+ }
73
+ /**
74
+ * Every `nb-<name>` on PATH, by name. The first directory on PATH wins, a name that is not plain or that a built-in
75
+ * command already uses is skipped, and a file that is not executable is not a tool.
76
+ */
77
+ export function findPlugins(pathEnv, reserved) {
78
+ if (process.platform === "win32" || !pathEnv)
79
+ return [];
80
+ const found = new Map();
81
+ for (const dir of pathEnv.split(delimiter)) {
82
+ if (!dir)
83
+ continue;
84
+ let entries;
85
+ try {
86
+ entries = readdirSync(dir);
87
+ }
88
+ catch {
89
+ continue;
90
+ }
91
+ for (const entry of entries) {
92
+ if (!entry.startsWith("nb-"))
93
+ continue;
94
+ const name = entry.slice(3);
95
+ if (!isPluginName(name) || reserved.has(name) || found.has(name))
96
+ continue;
97
+ const file = join(dir, entry);
98
+ if (!isExecutableFile(file))
99
+ continue;
100
+ found.set(name, { name, file, description: describePlugin(file, name) });
101
+ }
102
+ }
103
+ return [...found.values()].sort((a, b) => a.name.localeCompare(b.name));
104
+ }
105
+ /**
106
+ * What `nb <name> ...` should do with the command line, or undefined to let the CLI handle it as usual.
107
+ * Only the first word after `nb` is looked at: `nb secrets run ...` is a tool call, `nb --env local secrets` is not.
108
+ */
109
+ export function pluginCall(argv, pathEnv, reserved) {
110
+ const name = argv[2];
111
+ if (!name || !isPluginName(name) || reserved.has(name))
112
+ return undefined;
113
+ const plugin = findPlugins(pathEnv, reserved).find((p) => p.name === name);
114
+ if (plugin)
115
+ return { plugin, args: argv.slice(3) };
116
+ return name in KNOWN_TOOLS ? { missing: name } : undefined;
117
+ }
118
+ /** The "Tools" part of `nb -h`: what is installed with its description, and where to get the published tools that are not. */
119
+ export function pluginHelp(plugins) {
120
+ const lines = [""];
121
+ if (plugins.length > 0) {
122
+ lines.push("Tools (programs named nb-<name> on your PATH):");
123
+ const width = Math.max(...plugins.map((p) => p.name.length)) + 2;
124
+ for (const p of plugins)
125
+ lines.push(` ${p.name.padEnd(width)}${p.description}`.trimEnd());
126
+ lines.push("Run `nb <tool> -h` for a tool's own usage.");
127
+ }
128
+ const absent = Object.entries(KNOWN_TOOLS).filter(([name]) => !plugins.some((p) => p.name === name));
129
+ if (absent.length > 0) {
130
+ if (plugins.length > 0)
131
+ lines.push("");
132
+ lines.push("Other NASEBANAL tools (not installed; `nb <tool>` runs them once they are on your PATH):");
133
+ const width = Math.max(...absent.map(([name]) => name.length)) + 2;
134
+ for (const [name, t] of absent)
135
+ lines.push(` ${name.padEnd(width)}${t.repo}`);
136
+ }
137
+ return lines.join("\n") + "\n";
138
+ }
139
+ /** What `nb <name>` says when the tool is published but not on PATH. */
140
+ export function missingMessage(name) {
141
+ return (`nb: '${name}' is not installed. It is a separate tool, run by \`nb ${name}\` as \`nb-${name}\` from your PATH.\n` +
142
+ `Get it from ${KNOWN_TOOLS[name].repo}`);
143
+ }
144
+ /**
145
+ * Run the tool with the arguments after its name, the terminal and the environment as they are (plus
146
+ * `NB_PLUGIN_NAME=nb <name>`, so a tool can print its usage the way it was called). Resolves to the exit status.
147
+ */
148
+ export function runPlugin(plugin, args) {
149
+ return new Promise((resolve) => {
150
+ const child = spawn(plugin.file, args, {
151
+ stdio: "inherit",
152
+ env: { ...process.env, NB_PLUGIN_NAME: `nb ${plugin.name}` },
153
+ });
154
+ // Ctrl-C reaches the whole foreground group: the tool decides what to do with it (a passphrase prompt, say), and
155
+ // `nb` waits for it instead of leaving first. A terminate request is passed on.
156
+ const ignoreInterrupt = () => undefined;
157
+ const forwardTerminate = () => child.kill("SIGTERM");
158
+ process.on("SIGINT", ignoreInterrupt);
159
+ process.on("SIGTERM", forwardTerminate);
160
+ const done = (status) => {
161
+ process.off("SIGINT", ignoreInterrupt);
162
+ process.off("SIGTERM", forwardTerminate);
163
+ resolve(status);
164
+ };
165
+ child.on("error", (err) => {
166
+ process.stderr.write(`nb: cannot run ${plugin.file}: ${err.message}\n`);
167
+ done(126);
168
+ });
169
+ child.on("close", (code, signal) => {
170
+ if (code !== null)
171
+ return done(code);
172
+ const sig = signal ? osConstants.signals[signal] : undefined;
173
+ done(sig ? 128 + sig : 1);
174
+ });
175
+ });
176
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nasebanal/cli",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "gcloud-style command-line interface for NASEBANAL APIs, generated from nb-api-specs OpenAPI contracts.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -2,7 +2,7 @@ openapi: 3.0.3
2
2
  info:
3
3
  title: NASEBANAL Account API
4
4
  description: Centralized user and billing management API for NASEBANAL applications. Manages user profiles, per-service subscriptions, and Personal Access Tokens (PAT).
5
- version: 1.8.0
5
+ version: 1.9.0
6
6
  contact:
7
7
  name: NASEBANAL
8
8
  url: https://www.nasebanal.com
@@ -886,6 +886,267 @@ paths:
886
886
  $ref: "#/components/responses/Forbidden"
887
887
  "404":
888
888
  $ref: "#/components/responses/NotFound"
889
+ /api/v1/organizations/{orgId}/sso:
890
+ get:
891
+ tags:
892
+ - SSO
893
+ operationId: getOrganizationSso
894
+ summary: Get the SSO connection
895
+ description: Returns the SSO connection of the organization, or null when none is registered. Requires the caller to be an Org Admin and the organization to hold an active Enterprise subscription.
896
+ parameters:
897
+ - name: orgId
898
+ in: path
899
+ required: true
900
+ schema:
901
+ type: integer
902
+ responses:
903
+ "200":
904
+ description: The SSO connection, or null
905
+ content:
906
+ application/json:
907
+ schema:
908
+ type: object
909
+ required:
910
+ - success
911
+ - data
912
+ properties:
913
+ success:
914
+ type: boolean
915
+ enum:
916
+ - true
917
+ data:
918
+ allOf:
919
+ - $ref: "#/components/schemas/SsoConnection"
920
+ nullable: true
921
+ "401":
922
+ $ref: "#/components/responses/Unauthorized"
923
+ "403":
924
+ $ref: "#/components/responses/Forbidden"
925
+ "404":
926
+ $ref: "#/components/responses/NotFound"
927
+ put:
928
+ tags:
929
+ - SSO
930
+ operationId: putOrganizationSso
931
+ summary: Register or replace the SSO connection
932
+ description: "Creates the connection at the identity platform (turned off, not usable to log in yet) or replaces its IdP settings and domains, and returns the values to register in the IdP and the DNS TXT record to add for each domain. The client secret is write-only: it is never returned. A domain already verified by another organization is refused with 409."
933
+ parameters:
934
+ - name: orgId
935
+ in: path
936
+ required: true
937
+ schema:
938
+ type: integer
939
+ requestBody:
940
+ required: true
941
+ content:
942
+ application/json:
943
+ schema:
944
+ $ref: "#/components/schemas/SsoConnectionInput"
945
+ responses:
946
+ "200":
947
+ description: The connection after the change
948
+ content:
949
+ application/json:
950
+ schema:
951
+ type: object
952
+ required:
953
+ - success
954
+ - data
955
+ properties:
956
+ success:
957
+ type: boolean
958
+ enum:
959
+ - true
960
+ data:
961
+ $ref: "#/components/schemas/SsoConnection"
962
+ "400":
963
+ description: Invalid input
964
+ content:
965
+ application/json:
966
+ schema:
967
+ $ref: "#/components/schemas/Error"
968
+ example:
969
+ success: false
970
+ error:
971
+ code: VALIDATION_ERROR
972
+ message: domains must contain 1 to 5 valid domain names
973
+ "401":
974
+ $ref: "#/components/responses/Unauthorized"
975
+ "403":
976
+ $ref: "#/components/responses/Forbidden"
977
+ "404":
978
+ $ref: "#/components/responses/NotFound"
979
+ "409":
980
+ description: The request conflicts with the current state (domain claimed by another organization, or no verified domain yet)
981
+ content:
982
+ application/json:
983
+ schema:
984
+ $ref: "#/components/schemas/Error"
985
+ example:
986
+ success: false
987
+ error:
988
+ code: SSO_DOMAIN_TAKEN
989
+ message: This domain is already verified by another organization
990
+ "502":
991
+ description: The identity platform refused or failed the call
992
+ content:
993
+ application/json:
994
+ schema:
995
+ $ref: "#/components/schemas/Error"
996
+ example:
997
+ success: false
998
+ error:
999
+ code: SSO_PROVIDER_ERROR
1000
+ message: The identity platform could not complete the request
1001
+ delete:
1002
+ tags:
1003
+ - SSO
1004
+ operationId: deleteOrganizationSso
1005
+ summary: Delete the SSO connection
1006
+ description: Deletes the connection at the identity platform and its domains. People who signed in through it keep their accounts and can use another login method.
1007
+ parameters:
1008
+ - name: orgId
1009
+ in: path
1010
+ required: true
1011
+ schema:
1012
+ type: integer
1013
+ responses:
1014
+ "200":
1015
+ description: The connection was deleted
1016
+ content:
1017
+ application/json:
1018
+ schema:
1019
+ type: object
1020
+ required:
1021
+ - success
1022
+ - data
1023
+ properties:
1024
+ success:
1025
+ type: boolean
1026
+ enum:
1027
+ - true
1028
+ data:
1029
+ type: object
1030
+ properties:
1031
+ success:
1032
+ type: boolean
1033
+ "401":
1034
+ $ref: "#/components/responses/Unauthorized"
1035
+ "403":
1036
+ $ref: "#/components/responses/Forbidden"
1037
+ "404":
1038
+ $ref: "#/components/responses/NotFound"
1039
+ "502":
1040
+ description: The identity platform refused or failed the call
1041
+ content:
1042
+ application/json:
1043
+ schema:
1044
+ $ref: "#/components/schemas/Error"
1045
+ example:
1046
+ success: false
1047
+ error:
1048
+ code: SSO_PROVIDER_ERROR
1049
+ message: The identity platform could not complete the request
1050
+ /api/v1/organizations/{orgId}/sso/verify:
1051
+ post:
1052
+ tags:
1053
+ - SSO
1054
+ operationId: verifyOrganizationSsoDomains
1055
+ summary: Verify the domains
1056
+ description: Looks up the DNS TXT record of every pending domain and marks the ones that match as verified. Safe to call repeatedly.
1057
+ parameters:
1058
+ - name: orgId
1059
+ in: path
1060
+ required: true
1061
+ schema:
1062
+ type: integer
1063
+ responses:
1064
+ "200":
1065
+ description: The connection after the check
1066
+ content:
1067
+ application/json:
1068
+ schema:
1069
+ type: object
1070
+ required:
1071
+ - success
1072
+ - data
1073
+ properties:
1074
+ success:
1075
+ type: boolean
1076
+ enum:
1077
+ - true
1078
+ data:
1079
+ $ref: "#/components/schemas/SsoConnection"
1080
+ "401":
1081
+ $ref: "#/components/responses/Unauthorized"
1082
+ "403":
1083
+ $ref: "#/components/responses/Forbidden"
1084
+ "404":
1085
+ $ref: "#/components/responses/NotFound"
1086
+ /api/v1/organizations/{orgId}/sso/enabled:
1087
+ put:
1088
+ tags:
1089
+ - SSO
1090
+ operationId: setOrganizationSsoEnabled
1091
+ summary: Turn the SSO connection on or off
1092
+ description: Turning it on requires at least one verified domain; otherwise the call is refused with 409. Turning it off stops new logins through the connection and keeps its settings.
1093
+ parameters:
1094
+ - name: orgId
1095
+ in: path
1096
+ required: true
1097
+ schema:
1098
+ type: integer
1099
+ requestBody:
1100
+ required: true
1101
+ content:
1102
+ application/json:
1103
+ schema:
1104
+ $ref: "#/components/schemas/SsoEnabledInput"
1105
+ responses:
1106
+ "200":
1107
+ description: The connection after the change
1108
+ content:
1109
+ application/json:
1110
+ schema:
1111
+ type: object
1112
+ required:
1113
+ - success
1114
+ - data
1115
+ properties:
1116
+ success:
1117
+ type: boolean
1118
+ enum:
1119
+ - true
1120
+ data:
1121
+ $ref: "#/components/schemas/SsoConnection"
1122
+ "401":
1123
+ $ref: "#/components/responses/Unauthorized"
1124
+ "403":
1125
+ $ref: "#/components/responses/Forbidden"
1126
+ "404":
1127
+ $ref: "#/components/responses/NotFound"
1128
+ "409":
1129
+ description: The request conflicts with the current state (domain claimed by another organization, or no verified domain yet)
1130
+ content:
1131
+ application/json:
1132
+ schema:
1133
+ $ref: "#/components/schemas/Error"
1134
+ example:
1135
+ success: false
1136
+ error:
1137
+ code: SSO_NOT_VERIFIED
1138
+ message: Verify at least one domain before turning SSO on
1139
+ "502":
1140
+ description: The identity platform refused or failed the call
1141
+ content:
1142
+ application/json:
1143
+ schema:
1144
+ $ref: "#/components/schemas/Error"
1145
+ example:
1146
+ success: false
1147
+ error:
1148
+ code: SSO_PROVIDER_ERROR
1149
+ message: The identity platform could not complete the request
889
1150
  components:
890
1151
  securitySchemes:
891
1152
  BearerAuth:
@@ -1163,6 +1424,142 @@ components:
1163
1424
  minLength: 1
1164
1425
  maxLength: 200
1165
1426
  example: Acme Metrics Bot
1427
+ SsoConnection:
1428
+ type: object
1429
+ description: An organization's SSO connection. `status` is `pending` until a domain is verified, `disabled` once it is usable but off, and `enabled` when people can log in through it.
1430
+ required:
1431
+ - protocol
1432
+ - status
1433
+ - connection_name
1434
+ - domains
1435
+ - sp
1436
+ properties:
1437
+ protocol:
1438
+ type: string
1439
+ enum:
1440
+ - saml
1441
+ - oidc
1442
+ status:
1443
+ type: string
1444
+ enum:
1445
+ - pending
1446
+ - disabled
1447
+ - enabled
1448
+ connection_name:
1449
+ type: string
1450
+ description: Derived by the server (org-<id>-<protocol>); used as `?connection=` in the login URL.
1451
+ example: org-12-saml
1452
+ domains:
1453
+ type: array
1454
+ items:
1455
+ $ref: "#/components/schemas/SsoDomain"
1456
+ sp:
1457
+ $ref: "#/components/schemas/SsoServiceProviderValues"
1458
+ created_at:
1459
+ type: string
1460
+ format: date-time
1461
+ updated_at:
1462
+ type: string
1463
+ format: date-time
1464
+ SsoServiceProviderValues:
1465
+ type: object
1466
+ description: Values to register in the customer IdP so it trusts NASEBANAL.
1467
+ required:
1468
+ - entity_id
1469
+ - acs_url
1470
+ - redirect_uri
1471
+ properties:
1472
+ entity_id:
1473
+ type: string
1474
+ description: SAML Entity ID / Audience.
1475
+ example: urn:auth0:example-tenant:org-12-saml
1476
+ acs_url:
1477
+ type: string
1478
+ description: SAML Assertion Consumer Service URL.
1479
+ example: https://login.example.com/login/callback?connection=org-12-saml
1480
+ redirect_uri:
1481
+ type: string
1482
+ description: OIDC redirect URI (the same callback URL as `acs_url`).
1483
+ example: https://login.example.com/login/callback
1484
+ SsoDomain:
1485
+ type: object
1486
+ description: A domain whose ownership is proved with a DNS TXT record.
1487
+ required:
1488
+ - domain
1489
+ - verified
1490
+ - txt_record
1491
+ properties:
1492
+ domain:
1493
+ type: string
1494
+ example: example.com
1495
+ verified:
1496
+ type: boolean
1497
+ verified_at:
1498
+ type: string
1499
+ format: date-time
1500
+ nullable: true
1501
+ txt_record:
1502
+ type: object
1503
+ required:
1504
+ - name
1505
+ - value
1506
+ properties:
1507
+ name:
1508
+ type: string
1509
+ example: _nasebanal-verify.example.com
1510
+ value:
1511
+ type: string
1512
+ example: nb-verify=3f9c2a7e51b04d68
1513
+ SsoConnectionInput:
1514
+ type: object
1515
+ description: The IdP settings and domains to register. Give `saml` for protocol `saml`, and `oidc` for protocol `oidc`.
1516
+ required:
1517
+ - protocol
1518
+ - domains
1519
+ properties:
1520
+ protocol:
1521
+ type: string
1522
+ enum:
1523
+ - saml
1524
+ - oidc
1525
+ domains:
1526
+ type: array
1527
+ minItems: 1
1528
+ maxItems: 5
1529
+ items:
1530
+ type: string
1531
+ example: example.com
1532
+ saml:
1533
+ type: object
1534
+ description: IdP metadata. Give either `metadata_url` or `metadata_xml`.
1535
+ properties:
1536
+ metadata_url:
1537
+ type: string
1538
+ format: uri
1539
+ metadata_xml:
1540
+ type: string
1541
+ oidc:
1542
+ type: object
1543
+ required:
1544
+ - issuer
1545
+ - client_id
1546
+ - client_secret
1547
+ properties:
1548
+ issuer:
1549
+ type: string
1550
+ format: uri
1551
+ client_id:
1552
+ type: string
1553
+ client_secret:
1554
+ type: string
1555
+ writeOnly: true
1556
+ SsoEnabledInput:
1557
+ type: object
1558
+ required:
1559
+ - enabled
1560
+ properties:
1561
+ enabled:
1562
+ type: boolean
1166
1563
  Error:
1167
1564
  type: object
1168
1565
  required:
@@ -1272,5 +1669,7 @@ tags:
1272
1669
  description: Personal Access Token management
1273
1670
  - name: Service Accounts
1274
1671
  description: Org-scoped service accounts for Enterprise organizations and their API tokens. Org Admin only.
1672
+ - name: SSO
1673
+ description: "Enterprise single sign-on: an organization admin registers the company IdP (SAML or OIDC) and verifies the email domains. Org Admin only."
1275
1674
  - name: Notifications
1276
1675
  description: In-app notification inbox and mobile push device registration