|
13 | 13 | * { |
14 | 14 | * cloudUrl: string, // base URL of the upstream cloud ('' = same origin) |
15 | 15 | * upgradeUrl?: string, // absolute URL of the control plane's upgrade / billing entry — absent unless declared (#14514) |
| 16 | + * cloudHomeUrl?: string, // absolute URL of the control plane's console home page — absent unless declared (#34622) |
16 | 17 | * mapStyleUrl?: string, // the deployment's default map style (OS_CONSOLE_MAP_STYLE_URL) — absent unless set (#26001) |
17 | 18 | * singleEnvironment: boolean, |
18 | 19 | * defaultOrgId?, defaultEnvironmentId?, // multi-tenant, per-hostname |
@@ -726,6 +727,35 @@ export interface RuntimeConfigPluginConfig { |
726 | 727 | * whose control plane serves the page; the cloud subclass fills it. |
727 | 728 | */ |
728 | 729 | upgradeUrl?: string; |
| 730 | + /** |
| 731 | + * Absolute URL of the control plane's console home page, served verbatim |
| 732 | + * as the top-level `cloudHomeUrl` key beside `cloudUrl` and `upgradeUrl` |
| 733 | + * (#34622). |
| 734 | + * |
| 735 | + * The tenant Console's marketplace offers an "Open on Cloud" exit when it |
| 736 | + * cannot list the caller's cloud environments. Without this key it opens |
| 737 | + * `cloudUrl` itself — the control plane's origin, whose landing may route |
| 738 | + * a signed-in user straight back into the environment they came from. The |
| 739 | + * page that IS the control plane's console home belongs to whoever deploys |
| 740 | + * it, so it is declared here by that host, exactly as `upgradeUrl` is |
| 741 | + * (maintainer ruling cloud#1850, option A's shape), and the Console opens |
| 742 | + * it when the key is present. |
| 743 | + * |
| 744 | + * ⛔ Default **absent**: unset serves no `cloudHomeUrl` key at all, never an |
| 745 | + * empty string or a guessed default. A vanilla `objectstack dev`, a |
| 746 | + * self-hosted box and an air-gapped deployment have no control-plane |
| 747 | + * console, and the Console reads "no key" as "keep today's link". |
| 748 | + * Empty / whitespace-only reads as unset (absent, silent). |
| 749 | + * |
| 750 | + * ⛔ Must be ABSOLUTE (`http:` / `https:`). A relative path such as |
| 751 | + * `/_console` is refused and named at mount time, never forwarded: the |
| 752 | + * Console opens this URL from the TENANT origin, where a relative path |
| 753 | + * would resolve against the tenant runtime instead of the control plane. |
| 754 | + * |
| 755 | + * Host option only — no env var. The value belongs to the distribution |
| 756 | + * whose control plane serves the page; the cloud subclass fills it. |
| 757 | + */ |
| 758 | + cloudHomeUrl?: string; |
729 | 759 | /** |
730 | 760 | * CEILING for the `features.installLocal` flag — no longer its source |
731 | 761 | * (#8388). |
@@ -895,6 +925,10 @@ export class RuntimeConfigPlugin implements Plugin { |
895 | 925 | private readonly upgradeUrl: string | undefined; |
896 | 926 | /** The refused spelling, kept so `start()` can name it once — same reason as `refusedStage`. */ |
897 | 927 | private readonly refusedUpgradeUrl: string | undefined; |
| 928 | + /** The declared console home page, or `undefined` for "send no key" (unset or refused). */ |
| 929 | + private readonly cloudHomeUrl: string | undefined; |
| 930 | + /** The refused spelling, kept so `start()` can name it once — same reason as `refusedStage`. */ |
| 931 | + private readonly refusedCloudHomeUrl: string | undefined; |
898 | 932 | /** |
899 | 933 | * The deployment's default map style (`OS_CONSOLE_MAP_STYLE_URL`), or |
900 | 934 | * `undefined` for "send no key". Read in `start()`, which refuses a bad |
@@ -966,6 +1000,19 @@ export class RuntimeConfigPlugin implements Plugin { |
966 | 1000 | this.refusedUpgradeUrl = requestedUpgradeUrl !== undefined && this.upgradeUrl === undefined |
967 | 1001 | ? requestedUpgradeUrl |
968 | 1002 | : undefined; |
| 1003 | + // Control-plane console home page (#34622): the same contract as |
| 1004 | + // `upgradeUrl` above — empty reads as unset, a value that is not an |
| 1005 | + // absolute http(s) URL is refused and named at mount, an accepted one |
| 1006 | + // is kept verbatim. |
| 1007 | + const requestedCloudHomeUrl = typeof config.cloudHomeUrl === 'string' && config.cloudHomeUrl.trim() !== '' |
| 1008 | + ? config.cloudHomeUrl |
| 1009 | + : undefined; |
| 1010 | + this.cloudHomeUrl = requestedCloudHomeUrl !== undefined && isAbsoluteHttpUrl(requestedCloudHomeUrl) |
| 1011 | + ? requestedCloudHomeUrl |
| 1012 | + : undefined; |
| 1013 | + this.refusedCloudHomeUrl = requestedCloudHomeUrl !== undefined && this.cloudHomeUrl === undefined |
| 1014 | + ? requestedCloudHomeUrl |
| 1015 | + : undefined; |
969 | 1016 | const envLogoUrl = (typeof process !== 'undefined' ? process.env?.OS_LOGO_URL : undefined)?.trim(); |
970 | 1017 | const envFaviconUrl = (typeof process !== 'undefined' ? process.env?.OS_FAVICON_URL : undefined)?.trim(); |
971 | 1018 | const envBrandColor = (typeof process !== 'undefined' ? process.env?.OS_BRAND_COLOR : undefined)?.trim(); |
@@ -1073,6 +1120,17 @@ export class RuntimeConfigPlugin implements Plugin { |
1073 | 1120 | ); |
1074 | 1121 | } |
1075 | 1122 |
|
| 1123 | + // The same refusal for the control plane's console home page |
| 1124 | + // (#34622): declared, refused rather than coerced, and named once. |
| 1125 | + if (this.refusedCloudHomeUrl !== undefined) { |
| 1126 | + ctx.logger?.warn?.( |
| 1127 | + `[RuntimeConfigPlugin] ignoring cloudHomeUrl ${JSON.stringify(this.refusedCloudHomeUrl)} ` |
| 1128 | + + `(the \`cloudHomeUrl\` option): it must be an absolute http(s) URL — the Console opens it ` |
| 1129 | + + `from the tenant origin, so a relative path would resolve against the wrong host. ` |
| 1130 | + + `No cloudHomeUrl key is served and the Console's "Open on Cloud" link keeps its default target.`, |
| 1131 | + ); |
| 1132 | + } |
| 1133 | + |
1076 | 1134 | // Telemetry knobs the operator got wrong (#12681). Same shape and |
1077 | 1135 | // same reason as the stage refusal above: they meant to CONFIGURE |
1078 | 1136 | // something, the value was not understood, and it was refused |
@@ -1204,6 +1262,9 @@ export class RuntimeConfigPlugin implements Plugin { |
1204 | 1262 | // link", so a present-and-undefined property must never |
1205 | 1263 | // reach a non-JSON consumer or a test. |
1206 | 1264 | ...(this.upgradeUrl !== undefined ? { upgradeUrl: this.upgradeUrl } : {}), |
| 1265 | + // Declared by the host, never derived (#34622); spread for |
| 1266 | + // the same key-presence reason. |
| 1267 | + ...(this.cloudHomeUrl !== undefined ? { cloudHomeUrl: this.cloudHomeUrl } : {}), |
1207 | 1268 | // The operator's default map style (#26001); spread for |
1208 | 1269 | // the same key-presence reason. |
1209 | 1270 | ...(this.mapStyleUrl !== undefined ? { mapStyleUrl: this.mapStyleUrl } : {}), |
|
0 commit comments