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.

docs(tunnel,docusaurus): document token-mode tunnel and make docs baseUrl env-driven

Beenu Arorae3781a6f28fa
diff --git a/README.md b/README.md
index 1e9af22c4..486fb5a19 100644
--- a/README.md
+++ b/README.md
@@ -355,29 +355,35 @@ inbound ports are opened on your router or firewall.
- A domain whose DNS is managed by Cloudflare.
- The [`cloudflared`](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/get-started/) CLI installed locally (`brew install cloudflared` on macOS).
-- `cloudflared tunnel login` run once on this machine — it drops a `cert.pem` in `~/.cloudflared/` that authorises this host to manage tunnels and DNS records on the zone.
+- One of two auth methods (the script accepts either):
+ - **(A) Origin-cert flow:** run `cloudflared tunnel login` once on this machine — it drops a `cert.pem` in `~/.cloudflared/` that authorises this host to manage tunnels and DNS records on the zone. The script will then create the tunnel, render the ingress config, and wire DNS automatically.
+ - **(B) Tunnel-token flow ★:** create a tunnel in the Cloudflare Zero Trust dashboard (Networks → Tunnels → *Create a tunnel* → Cloudflared), configure the four public hostnames (apex/api/ws/docs → `localhost:3000/8000/8086/3001`), and copy the `--token ey…` value the dashboard hands you. No `cert.pem` required, no local DNS plumbing. Useful when the browser-based `cloudflared tunnel login` won't write a cert (corporate browsers, headless boxes, etc).
#### Run it
```bash
-# Default: tryaisoc.com (apex → web, api/ws/docs.tryaisoc.com → api/realtime/docs)
-pnpm demo:public
+# (A) Origin-cert flow — script manages tunnel, ingress, and DNS:
+pnpm demo:public # default: tryaisoc.com
+DOMAIN=demo.example.com pnpm demo:public # any zone you control
-# Or point it at any zone you control:
-DOMAIN=demo.example.com pnpm demo:public
+# (B) Tunnel-token flow — dashboard owns the tunnel, ingress, and DNS:
+export CLOUDFLARE_TUNNEL_TOKEN='ey…' # paste the token from the dashboard
+pnpm demo:public # script auto-detects the token
# Already have the local stack running? Just bring the tunnel up:
-pnpm demo:public:tunnel-only
+pnpm demo:public:tunnel-only # works for both auth modes
# Just provision the tunnel + DNS, but don't run cloudflared
-# (useful before `cloudflared service install` to leave it running 24/7):
+# (origin-cert flow only — useful before `cloudflared service install`
+# to leave it running 24/7):
SKIP_RUN=1 pnpm demo:public:setup
```
All env vars are forwarded to [`infra/cloudflare/tunnel.sh`](infra/cloudflare/tunnel.sh):
-`DOMAIN` (apex, default `tryaisoc.com`), `TUNNEL_NAME` (default `aisoc-tryaisoc`),
-`SUBDOMAINS` (default `"api ws docs"`), `SKIP_DNS=1` (don't touch DNS records),
-`SKIP_RUN=1` (set up everything but don't run the tunnel).
+`DOMAIN` (apex, default `tryaisoc.com`), `TUNNEL_NAME` (default `aisoc-tryaisoc`,
+ignored in token mode), `SUBDOMAINS` (default `"api ws docs"`, ignored in token
+mode), `SKIP_DNS=1` (don't touch DNS records), `SKIP_RUN=1` (set up everything
+but don't run the tunnel), and `CLOUDFLARE_TUNNEL_TOKEN` (switch to flow B).
Run `bash scripts/demo-public.sh --help` to see the full set, or read
[`infra/cloudflare/README.md`](infra/cloudflare/README.md) for the topology
diagram and production-hardening notes (running `cloudflared` as a launchd /
diff --git a/apps/docs/docusaurus.config.ts b/apps/docs/docusaurus.config.ts
index fd2442798..04b62a1ba 100644
--- a/apps/docs/docusaurus.config.ts
+++ b/apps/docs/docusaurus.config.ts
@@ -2,14 +2,23 @@ import { themes as prismThemes } from "prism-react-renderer";
import type { Config } from "@docusaurus/types";
import type * as Preset from "@docusaurus/preset-classic";
+// Two deploy targets share this build:
+// 1. GitHub Pages (default): https://beenuar.github.io/AiSOC/
+// 2. Custom domain : https://docs.tryaisoc.com/ (served behind cloudflared tunnel)
+//
+// Override at build time with:
+// DOCS_URL=https://docs.tryaisoc.com DOCS_BASE_URL=/ pnpm --filter @aisoc/docs build
+const DOCS_URL = process.env.DOCS_URL || "https://beenuar.github.io";
+const DOCS_BASE_URL = process.env.DOCS_BASE_URL || "/AiSOC/";
+
const config: Config = {
title: "AiSOC",
tagline:
"Open-source AI SOC platform. Agent decisions are recorded in an investigation ledger and a public eval harness runs in CI. MIT-licensed and self-hostable.",
favicon: "img/favicon.ico",
- url: "https://beenuar.github.io",
- baseUrl: "/AiSOC/",
+ url: DOCS_URL,
+ baseUrl: DOCS_BASE_URL,
organizationName: "beenuar",
projectName: "AiSOC",
diff --git a/infra/cloudflare/README.md b/infra/cloudflare/README.md
index daa46d640..96a6bfcb4 100644
--- a/infra/cloudflare/README.md
+++ b/infra/cloudflare/README.md
@@ -21,13 +21,59 @@ own machine without opening a single inbound port on your router or firewall.
2. **A Cloudflare account that owns `tryaisoc.com`** (or any other zone you
control — point `tunnel.sh` at it via the `DOMAIN` env var; no source edits
required).
-3. **Login once** — `cloudflared tunnel login`. This drops a `cert.pem` in
- `~/.cloudflared/` that authorises this machine to manage tunnels and DNS
- for the zone.
+3. **One auth method** (see *Two auth modes* below).
4. **A running stack** — the demo profile from `pnpm aisoc:demo` is the
intended target. The wrapper `pnpm demo:public` (see below) brings the
stack up and the tunnel up in one command.
+## Two auth modes
+
+`tunnel.sh` accepts either of the two auth shapes Cloudflare supports today.
+The script auto-detects which one is in use; you only need to supply one.
+
+### (A) Origin-cert mode — default
+
+Run `cloudflared tunnel login` once. It opens a browser, you pick the zone, and
+`cloudflared` writes `~/.cloudflared/cert.pem`. From there, `tunnel.sh` will:
+
+1. Create / reuse the named tunnel (`TUNNEL_NAME`, default `aisoc-tryaisoc`).
+2. Render `config.yml` from `config.yml.example`.
+3. Add DNS routes for the apex + each subdomain in `SUBDOMAINS`.
+4. Run `cloudflared tunnel run` against the rendered config.
+
+Choose this mode when you want one command to provision the tunnel,
+ingress, and DNS records.
+
+### (B) Tunnel-token mode — for headless / restricted-browser hosts
+
+If `cloudflared tunnel login` won't write a cert (corporate browsers, locked-down
+machines, headless servers, etc), create the tunnel in the [Cloudflare Zero Trust
+dashboard](https://one.dash.cloudflare.com/) instead:
+
+1. **Networks → Tunnels → Create a tunnel → Cloudflared.**
+2. Name the tunnel (e.g. `aisoc-tryaisoc`) and copy the long `--token ey…` value
+ the dashboard hands you.
+3. **Public Hostnames** tab — add four entries on the zone you control:
+
+ | Subdomain | Type | URL |
+ | --------- | ------ | ------------------------- |
+ | *(apex)* | `HTTP` | `localhost:3000` |
+ | `api` | `HTTP` | `localhost:8000` |
+ | `ws` | `HTTP` | `localhost:8086` |
+ | `docs` | `HTTP` | `localhost:3001` |
+
+4. Export the token and run the wrapper:
+
+ ```sh
+ export CLOUDFLARE_TUNNEL_TOKEN='ey…'
+ pnpm demo:public # or: pnpm demo:public:tunnel-only
+ ```
+
+When `CLOUDFLARE_TUNNEL_TOKEN` is set, `tunnel.sh` skips `cert.pem`, the local
+`config.yml` render, and the DNS-route step — the dashboard owns all of that —
+and execs `cloudflared tunnel run --token <token>` directly. `TUNNEL_NAME` and
+`SUBDOMAINS` are ignored in this mode (the dashboard already knows them).
+
## Topology
```
@@ -103,9 +149,9 @@ pnpm aisoc:demo # or: docker compose -f docker-compose.demo.yml up -d
bash infra/cloudflare/tunnel.sh
```
-`tunnel.sh` will:
+`tunnel.sh` in **origin-cert mode** (default, no token set) will:
-1. Verify `cloudflared` is installed and authenticated.
+1. Verify `cloudflared` is installed and authenticated (`~/.cloudflared/cert.pem`).
2. Create a tunnel named `aisoc-tryaisoc` (configurable via `TUNNEL_NAME`) if
it doesn't already exist.
3. Render `config.yml` from `config.yml.example`, substituting the tunnel
@@ -116,6 +162,13 @@ bash infra/cloudflare/tunnel.sh
`SUBDOMAINS` (default `"api ws docs"`).
6. Run `cloudflared tunnel --config <generated-config> run`.
+`tunnel.sh` in **token mode** (`CLOUDFLARE_TUNNEL_TOKEN` set) will:
+
+1. Verify `cloudflared` is installed.
+2. Skip everything cert-bound (no `cert.pem` check, no `config.yml` render, no
+ DNS routes, no `TUNNEL_NAME` lookup) — the dashboard owns all of that.
+3. Exec `cloudflared tunnel run --token "$CLOUDFLARE_TUNNEL_TOKEN"`.
+
The first run takes ~10 seconds for DNS propagation; subsequent runs are
instant.
@@ -124,14 +177,15 @@ instant.
Both `pnpm demo:public*` and `bash infra/cloudflare/tunnel.sh` honour the
same set:
-| Var | Default | Purpose |
-| ------------- | ---------------- | -------------------------------------------------------- |
-| `DOMAIN` | `tryaisoc.com` | Apex domain. The script routes `DOMAIN` and each subdomain in `SUBDOMAINS` to the tunnel. |
-| `TUNNEL_NAME` | `aisoc-tryaisoc` | Cloudflare tunnel name. Reused if it already exists. |
-| `SUBDOMAINS` | `"api ws docs"` | Space-separated list of subdomains to route in addition to the apex. |
-| `SKIP_DNS` | *(unset)* | If set to `1`, don't touch DNS records (assume they exist). |
-| `SKIP_RUN` | *(unset)* | If set to `1`, set everything up but don't run the tunnel — pair with `cloudflared service install` for a 24/7 setup. |
-| `CFD_DIR` | `~/.cloudflared` | Where `cloudflared`'s `cert.pem`, credentials JSONs, and rendered configs live. |
+| Var | Default | Purpose |
+| ------------------------- | ---------------- | -------------------------------------------------------- |
+| `DOMAIN` | `tryaisoc.com` | Apex domain. In **origin-cert mode** the script routes `DOMAIN` and each subdomain in `SUBDOMAINS` to the tunnel. In **token mode** it's used purely for log/banner output (the dashboard already knows the hostnames). |
+| `TUNNEL_NAME` | `aisoc-tryaisoc` | Cloudflare tunnel name. Reused if it already exists. **Ignored in token mode** — the dashboard owns the tunnel name. |
+| `SUBDOMAINS` | `"api ws docs"` | Space-separated list of subdomains to route in addition to the apex. **Ignored in token mode** — the dashboard already routes them. |
+| `SKIP_DNS` | *(unset)* | If set to `1`, don't touch DNS records (assume they exist). **No-op in token mode** — DNS is already managed by the dashboard. |
+| `SKIP_RUN` | *(unset)* | If set to `1`, set everything up but don't run the tunnel — pair with `cloudflared service install` for a 24/7 setup. Honoured in both modes. |
+| `CFD_DIR` | `~/.cloudflared` | Where `cloudflared`'s `cert.pem`, credentials JSONs, and rendered configs live. **Only consulted in origin-cert mode.** |
+| `CLOUDFLARE_TUNNEL_TOKEN` | *(unset)* | If set, switches the script to **token mode**: skips `cert.pem` / tunnel-create / DNS / config-render and execs `cloudflared tunnel run --token <value>` directly. Use the long `ey…` token from the Cloudflare Zero Trust dashboard (Networks → Tunnels → Install connector → Docker tab). |
`scripts/demo-public.sh --help` documents the wrapper-level flags
(`--skip-stack`, `--no-open`, etc.) on top of these.
@@ -170,7 +224,8 @@ DOMAIN=aisoc.example.com SKIP_RUN=1 pnpm demo:public:setup
```
Cloudflare needs to manage DNS for the zone, and you need to have run
-`cloudflared tunnel login` once for that account. Everything else is
+`cloudflared tunnel login` once for that account (origin-cert mode) — *or* set
+`CLOUDFLARE_TUNNEL_TOKEN` from the dashboard (token mode). Everything else is
parameterised.
## Stopping
@@ -179,14 +234,23 @@ parameterised.
running. To take everything down:
```sh
+# Bring the local stack down (works in either auth mode):
pnpm aisoc:demo:down
-cloudflared tunnel delete aisoc-tryaisoc # only if you want to release the tunnel + DNS
+
+# Origin-cert mode only — release the tunnel + DNS records the script created:
+cloudflared tunnel delete aisoc-tryaisoc
+
+# Token mode — delete the tunnel from the Cloudflare Zero Trust dashboard
+# (Networks → Tunnels → … → Delete). The CLI command above won't work here
+# because this machine has no cert.pem to authorise the delete.
```
## Production-grade extras (optional)
If you want to leave the demo up 24/7 without a terminal window pinned, run
-`cloudflared` as a launchd / systemd service:
+`cloudflared` as a launchd / systemd service.
+
+**Origin-cert mode** — point the service at the rendered config:
```sh
# macOS
@@ -197,7 +261,16 @@ sudo cloudflared service install \
sudo cloudflared service install
```
-`cloudflared service uninstall` reverses it.
+**Token mode** — install the service with the dashboard token. The command the
+Cloudflare dashboard hands you on the *Install connector → Docker* tab also
+works for `service install`:
+
+```sh
+# macOS / Linux
+sudo cloudflared service install ey… # paste the same token you use locally
+```
+
+`cloudflared service uninstall` reverses either flavour.
## What the tunnel does NOT do