Skip to content

armgit / AiSOC

Public Imported from GitHub
0

Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.

fix(web): a self-hosted install's root lands on the console, not the marketing page (#1561)

Beenu Arora8ebedd2fcf3f
diff --git a/.github/workflows/compose-smoke-nightly.yml b/.github/workflows/compose-smoke-nightly.yml
index a849381cd..1d246d698 100644
--- a/.github/workflows/compose-smoke-nightly.yml
+++ b/.github/workflows/compose-smoke-nightly.yml
@@ -111,7 +111,12 @@ jobs:
probe_http() {
local url="$1" expect="$2"
local code
- code=$(curl --silent --output /dev/null --write-out '%{http_code}' \
+ # --location: the console's / answers 307 -> /login by design
+ # (AISOC_MARKETING_HOME, discussion #1549), so the probe follows
+ # redirects and asserts the *final* document's status — which also
+ # proves the login page renders, a stronger check than "anything
+ # answered at /".
+ code=$(curl --silent --location --output /dev/null --write-out '%{http_code}' \
--max-time 5 "$url" || echo "000")
[ "$code" = "$expect" ]
}
diff --git a/.github/workflows/compose-smoke.yml b/.github/workflows/compose-smoke.yml
index 37223314e..96c224f62 100644
--- a/.github/workflows/compose-smoke.yml
+++ b/.github/workflows/compose-smoke.yml
@@ -519,7 +519,12 @@ jobs:
probe_http() {
local url="$1" expect="$2"
local code
- code=$(curl --silent --output /dev/null --write-out '%{http_code}' \
+ # --location: the console's / answers 307 -> /login by design
+ # (AISOC_MARKETING_HOME, discussion #1549), so the probe follows
+ # redirects and asserts the *final* document's status — which also
+ # proves the login page renders, a stronger check than "anything
+ # answered at /".
+ code=$(curl --silent --location --output /dev/null --write-out '%{http_code}' \
--max-time 5 "$url" || echo "000")
[ "$code" = "$expect" ]
}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 59a13a819..0a7ad12d7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Changed
+
+- **The console's root URL now lands an operator on their console.** On a
+ clean self-hosted install, `/` rendered the project's marketing landing
+ page — neither the dashboard nor the login page the operator was looking
+ for (reported in discussion #1549). `/` now redirects to `/login`, which
+ already routes onward: a first run lands on the setup wizard and a
+ signed-in session on `/dashboard`. The marketing page remains the root for
+ deployments that *are* the public project site, by setting
+ `AISOC_MARKETING_HOME` in the running container (runtime outranks the
+ build-time `NEXT_PUBLIC_MARKETING_HOME`, the same relationship
+ `AISOC_DEMO_MODE` has to its build-time twin, because `NEXT_PUBLIC_*` is
+ frozen into a pulled image). The root route is `force-dynamic` so the
+ answer comes from the container's environment on every request, and the
+ decision is pinned in both directions by `apps/web/src/app/page.test.tsx`.
+
### Security
- **Dependencies:** `decode-uri-component` 0.5.0 → 0.5.1 in the mobile
diff --git a/apps/docs/docs/deployment/env-vars.md b/apps/docs/docs/deployment/env-vars.md
index 2ec51de2c..2655e144e 100644
--- a/apps/docs/docs/deployment/env-vars.md
+++ b/apps/docs/docs/deployment/env-vars.md
@@ -483,6 +483,7 @@ which is why there is no CORS to configure.
| `AISOC_AGENTS_URL` | `http://agents:8084` | Agents service (copilot, hunt, playbooks) |
| `AISOC_REALTIME_URL` | `http://realtime:4000` | Realtime gateway for `/ws/*` and `/sse` |
| `AISOC_DEMO_MODE` | `false` | Whether this deployment is a demo. Reported at `/api/runtime-config` |
+| `AISOC_MARKETING_HOME` | `false` | When `true`, `/` serves the project's marketing landing page. Default is the console: `/` redirects to `/login`, which routes onward (first run → setup wizard, signed in → dashboard) |
| `AISOC_CONSOLE_BIND_ADDR` | `127.0.0.1` | Interface the console's host port publishes on |
| `AISOC_BIND_ADDR` | `127.0.0.1` | Interface **every** host port publishes on, datastores included |
@@ -498,6 +499,7 @@ leave them empty and let same-origin proxying handle it, which is the default.
| `NEXT_PUBLIC_API_URL` | *(empty)* | Absolute API origin for the browser. Empty means same-origin; setting it opts into configuring CORS |
| `NEXT_PUBLIC_WS_URL` | *(empty)* | Absolute WebSocket origin. Empty derives it from the page's own origin |
| `NEXT_PUBLIC_DEMO_MODE` | *(empty)* | Compiles the image as a demo build. `AISOC_DEMO_MODE` overrides it at run time |
+| `NEXT_PUBLIC_MARKETING_HOME` | *(empty)* | Compiles the image with the marketing page at `/`. `AISOC_MARKETING_HOME` overrides it at run time |
| `NEXT_PUBLIC_VAPID_PUBLIC_KEY` | — | Must match the realtime service's `VAPID_PUBLIC_KEY` |
See [Single-host deployment](./single-host.md) for the whole path end to end.
diff --git a/apps/web/src/app/page.test.tsx b/apps/web/src/app/page.test.tsx
new file mode 100644
index 000000000..fcfa38a27
--- /dev/null
+++ b/apps/web/src/app/page.test.tsx
@@ -0,0 +1,100 @@
+/**
+ * The root of a self-hosted install must land an operator on their console.
+ *
+ * Discussion #1549: a clean server's `/` rendered the project's marketing
+ * landing page — neither the dashboard nor the login page the operator was
+ * looking for. The default is now a redirect to `/login` (which routes
+ * onward: first run → onboarding, an authenticated session → `/dashboard`),
+ * and the marketing landing renders only when the deployment opts in as the
+ * public project site.
+ *
+ * Both directions are pinned, because a one-sided suite would pass equally
+ * well on a tree that deleted the marketing page outright — and the page is
+ * still the project site's homepage when asked for.
+ *
+ * `HomePage()` is called as a plain function: in console mode the redirect
+ * throws before any JSX exists, and in marketing mode the returned element
+ * tree is lazy, so none of the section components execute. That keeps this
+ * test independent of every landing section.
+ */
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+const redirectMock = vi.hoisted(() =>
+ vi.fn((target: string): never => {
+ throw new Error(`NEXT_REDIRECT:${target}`);
+ }),
+);
+
+vi.mock('next/navigation', () => ({
+ __esModule: true,
+ redirect: redirectMock,
+}));
+
+// `next/font/google` executes only under the Next compiler, and the four
+// eagerly-imported sections are client components this test never renders
+// (the dynamic ones are already lazy). Same pattern as not-found.test.tsx.
+vi.mock('@/lib/marketing-fonts', () => ({ __esModule: true, velvetFontVariables: '' }));
+vi.mock('@/components/landing/sections/StickyNav', () => ({ __esModule: true, StickyNav: () => null }));
+vi.mock('@/components/landing/sections/Hero', () => ({ __esModule: true, Hero: () => null }));
+vi.mock('@/components/landing/sections/ProofStrip', () => ({ __esModule: true, ProofStrip: () => null }));
+vi.mock('@/components/landing/sections/Problem', () => ({ __esModule: true, Problem: () => null }));
+
+import HomePage, { dynamic as routeDynamic } from './page';
+import { __setMarketingHomeForTests, homeRouteReport } from '@/lib/homeRoute';
+
+afterEach(() => {
+ __setMarketingHomeForTests(null);
+ vi.unstubAllEnvs();
+ redirectMock.mockClear();
+});
+
+describe('the root route of a self-hosted install', () => {
+ it('redirects to /login by default', () => {
+ expect(() => HomePage()).toThrowError('NEXT_REDIRECT:/login');
+ expect(redirectMock).toHaveBeenCalledWith('/login');
+ });
+
+ it('still redirects when the runtime flag is explicitly off', () => {
+ vi.stubEnv('AISOC_MARKETING_HOME', 'false');
+ expect(() => HomePage()).toThrowError('NEXT_REDIRECT:/login');
+ });
+
+ it('renders the marketing landing when the running container opts in', () => {
+ vi.stubEnv('AISOC_MARKETING_HOME', 'true');
+ const element = HomePage();
+ expect(element).toBeTruthy();
+ expect(redirectMock).not.toHaveBeenCalled();
+ });
+
+ it('is force-dynamic, so the answer comes from the container on every request', () => {
+ // Statically optimised, the build machine's environment would be compiled
+ // into the route and a pulled image could never be steered — the defect
+ // class runtime-over-build exists to avoid.
+ expect(routeDynamic).toBe('force-dynamic');
+ });
+});
+
+describe('homeRouteReport', () => {
+ it('defaults to the console and says so', () => {
+ expect(homeRouteReport()).toEqual({ marketing: false, source: 'default' });
+ });
+
+ it('runtime value outranks the build-time value, in both directions', () => {
+ vi.stubEnv('NEXT_PUBLIC_MARKETING_HOME', 'true');
+ expect(homeRouteReport()).toEqual({ marketing: true, source: 'build' });
+
+ vi.stubEnv('AISOC_MARKETING_HOME', 'false');
+ expect(homeRouteReport()).toEqual({ marketing: false, source: 'runtime' });
+
+ vi.stubEnv('AISOC_MARKETING_HOME', 'true');
+ vi.stubEnv('NEXT_PUBLIC_MARKETING_HOME', 'false');
+ expect(homeRouteReport()).toEqual({ marketing: true, source: 'runtime' });
+ });
+
+ it('reads the environment on every call rather than caching the first answer', () => {
+ vi.stubEnv('AISOC_MARKETING_HOME', 'true');
+ expect(homeRouteReport().marketing).toBe(true);
+ vi.stubEnv('AISOC_MARKETING_HOME', 'false');
+ expect(homeRouteReport().marketing).toBe(false);
+ });
+});
diff --git a/apps/web/src/app/page.tsx b/apps/web/src/app/page.tsx
index 0579d6c4c..e0c814d8c 100644
--- a/apps/web/src/app/page.tsx
+++ b/apps/web/src/app/page.tsx
@@ -1,6 +1,8 @@
import type { Metadata } from 'next';
-import dynamic from 'next/dynamic';
+import nextDynamic from 'next/dynamic';
+import { redirect } from 'next/navigation';
import { docs } from '@/lib/docs';
+import { homeRouteReport } from '@/lib/homeRoute';
import { getPublicSiteUrl } from '@/lib/site';
import { velvetFontVariables } from '@/lib/marketing-fonts';
import { StickyNav } from '@/components/landing/sections/StickyNav';
@@ -11,7 +13,18 @@ import { CONNECTOR_COUNT } from '@/data/connectorCount';
import { EXECUTABLE_DETECTION_COUNT } from '@/data/corpusStats';
/**
- * AiSOC root (`/`) — marketing landing page.
+ * AiSOC root (`/`) — the console's front door by default, the marketing
+ * landing page on deployments that opt in.
+ *
+ * On a self-hosted install the root redirects to `/login`, which routes
+ * onward by itself (first run → the onboarding wizard, an authenticated
+ * session → `/dashboard`). The marketing sections below render only when the
+ * deployment says it is the public project site (`AISOC_MARKETING_HOME` in
+ * the running container — see `lib/homeRoute.ts`, including why the route is
+ * `force-dynamic`: the answer must come from the container's environment on
+ * every request, not from whatever was compiled into the image). Reported in
+ * discussion #1549 by an operator whose clean server greeted them with a
+ * marketing page.
*
* Two sections here were arguments made out of nothing. `DemoEmbed` drew a
* hand-authored Investigation Ledger — an invented incident id, an invented
@@ -43,43 +56,43 @@ import { EXECUTABLE_DETECTION_COUNT } from '@/data/corpusStats';
* still honours the toggle, which is what AGENTS.md WS-F1 promised.
*/
-const SolutionAgents = dynamic(
+const SolutionAgents = nextDynamic(
() => import('@/components/landing/sections/SolutionAgents').then((m) => m.SolutionAgents),
);
-const ProductTour = dynamic(
+const ProductTour = nextDynamic(
() => import('@/components/landing/sections/ProductTour').then((m) => m.ProductTour),
);
-const Pillars = dynamic(
+const Pillars = nextDynamic(
() => import('@/components/landing/sections/Pillars').then((m) => m.Pillars),
);
-const FeatureGrid = dynamic(
+const FeatureGrid = nextDynamic(
() => import('@/components/landing/sections/FeatureGrid').then((m) => m.FeatureGrid),
);
-const ConnectorsMarquee = dynamic(
+const ConnectorsMarquee = nextDynamic(
() => import('@/components/landing/sections/ConnectorsMarquee').then((m) => m.ConnectorsMarquee),
);
-const BenchmarkBand = dynamic(
+const BenchmarkBand = nextDynamic(
() => import('@/components/landing/sections/BenchmarkBand').then((m) => m.BenchmarkBand),
);
-const DeployOptions = dynamic(
+const DeployOptions = nextDynamic(
() => import('@/components/landing/sections/DeployOptions').then((m) => m.DeployOptions),
);
-const OpenSourceMoment = dynamic(
+const OpenSourceMoment = nextDynamic(
() => import('@/components/landing/sections/OpenSourceMoment').then((m) => m.OpenSourceMoment),
);
-const HonestLimits = dynamic(
+const HonestLimits = nextDynamic(
() => import('@/components/landing/sections/HonestLimits').then((m) => m.HonestLimits),
);
-const PricingTeaser = dynamic(
+const PricingTeaser = nextDynamic(
() => import('@/components/landing/sections/PricingTeaser').then((m) => m.PricingTeaser),
);
-const Faq = dynamic(
+const Faq = nextDynamic(
() => import('@/components/landing/sections/Faq').then((m) => m.Faq),
);
-const FinalCta = dynamic(
+const FinalCta = nextDynamic(
() => import('@/components/landing/sections/FinalCta').then((m) => m.FinalCta),
);
-const Footer = dynamic(
+const Footer = nextDynamic(
() => import('@/components/landing/sections/Footer').then((m) => m.Footer),
);
@@ -238,7 +251,16 @@ const faqJsonLd = {
],
};
+// The home decision reads the running container's environment on every
+// request (see lib/homeRoute.ts). Without this, Next would statically
+// optimise the route at build time and the compiled answer would win on
+// every pulled image — the exact defect runtime-over-build exists to avoid.
+export const dynamic = 'force-dynamic';
+
export default function HomePage() {
+ if (!homeRouteReport().marketing) {
+ redirect('/login');
+ }
return (
<>
<script
diff --git a/apps/web/src/lib/homeRoute.ts b/apps/web/src/lib/homeRoute.ts
new file mode 100644
index 000000000..01f7896e1
--- /dev/null
+++ b/apps/web/src/lib/homeRoute.ts
@@ -0,0 +1,78 @@
+/**
+ * What the root URL (`/`) of this deployment is for.
+ *
+ * A clean self-hosted install's root must land an operator on their console,
+ * not on a marketing page. That is not hypothetical: discussion #1549 is an
+ * operator who deployed on a clean server and found that "the default
+ * homepage is not the dashboard or the login page". The marketing landing is
+ * real content — but it is the *project site's* homepage, and a specific
+ * deployment serving it at `/` is the same class of defect as one install's
+ * branding showing up inside another's product.
+ *
+ * The default is therefore the console: `/` redirects to `/login`, which
+ * already routes onward (first run → the onboarding wizard, an authenticated
+ * session → `/dashboard`, a sanitized `?next=` when one was asked for). A
+ * deployment that *is* the public project site opts back in by setting
+ * `AISOC_MARKETING_HOME` in the running container.
+ *
+ * Runtime (`AISOC_MARKETING_HOME`) outranks build time
+ * (`NEXT_PUBLIC_MARKETING_HOME`) for the same reason `AISOC_DEMO_MODE`
+ * outranks its build-time twin in `demoMode.ts`: Next inlines `NEXT_PUBLIC_*`
+ * values when the image is *built*, so on a pulled image the compiled answer
+ * is frozen and the running container's environment is the only thing an
+ * operator can actually steer. This module is read from a Server Component
+ * on a `force-dynamic` route, so the runtime value is consulted on every
+ * request rather than baked at build.
+ */
+
+const TRUTHY = new Set(['1', 'true', 'yes', 'on']);
+
+let _override: boolean | null = null;
+
+/** Where the answer came from, so an operator never has to infer it. */
+export type HomeRouteSource =
+ /** `AISOC_MARKETING_HOME` in the running container. Outranks the compiled value. */
+ | 'runtime'
+ /** `NEXT_PUBLIC_MARKETING_HOME`, fixed when the image was built. */
+ | 'build'
+ /** Neither was set. The root is the console. */
+ | 'default'
+ /** `__setMarketingHomeForTests` is in force. */
+ | 'test-override';
+
+export interface HomeRouteReport {
+ /** True when `/` renders the marketing landing page. */
+ marketing: boolean;
+ source: HomeRouteSource;
+}
+
+function truthy(raw: string | undefined): boolean | null {
+ const v = raw?.toLowerCase().trim() ?? '';
+ if (v === '') return null;
+ return TRUTHY.has(v);
+}
+
+/**
+ * The single authoritative answer to "what does `/` serve here", and where
+ * it came from. Reads the environment on every call — no module-level cache —
+ * so the running container's value, not the first request's, is what wins.
+ */
+export function homeRouteReport(): HomeRouteReport {
+ if (_override !== null) {
+ return { marketing: _override, source: 'test-override' };
+ }
+ const runtime = truthy(process.env.AISOC_MARKETING_HOME);
+ if (runtime !== null) {
+ return { marketing: runtime, source: 'runtime' };
+ }
+ const build = truthy(process.env.NEXT_PUBLIC_MARKETING_HOME);
+ if (build !== null) {
+ return { marketing: build, source: 'build' };
+ }
+ return { marketing: false, source: 'default' };
+}
+
+/** Test seam, mirroring `__setDemoModeForTests`. Pass `null` to clear. */
+export function __setMarketingHomeForTests(value: boolean | null): void {
+ _override = value;
+}