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): wire Settings Workspace/About panels to real tenant data (#648)

Beenu Arora20378deaa57f
diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile
index 9a9ad603c..f38528cf2 100644
--- a/apps/web/Dockerfile
+++ b/apps/web/Dockerfile
@@ -16,6 +16,7 @@ COPY package.json pnpm-workspace.yaml ./
COPY pnpm-lock.yaml* ./
COPY turbo.json ./
COPY tsconfig.base.json ./
+COPY VERSION ./
COPY packages ./packages
COPY apps/web ./apps/web
diff --git a/apps/web/next.config.js b/apps/web/next.config.js
index ebb340eb0..5b6d1e971 100644
--- a/apps/web/next.config.js
+++ b/apps/web/next.config.js
@@ -1,7 +1,23 @@
/** @type {import('next').NextConfig} */
+const fs = require('fs');
const path = require('path');
+// Repo-root VERSION file is the single source of truth for the app version
+// shown in Settings → About. Baked into the bundle at build time since the
+// browser has no way to read a file off the deployed container's disk.
+// Falls back to "0.0.0" rather than failing the build if some build context
+// doesn't carry the file through (e.g. a Dockerfile COPY list falling out of
+// sync, or `next build` invoked from an unexpected working directory).
+let APP_VERSION = '0.0.0';
+try {
+ APP_VERSION = fs
+ .readFileSync(path.resolve(__dirname, '..', '..', 'VERSION'), 'utf8')
+ .trim();
+} catch {
+ console.warn('[next.config.js] Could not read repo-root VERSION file; using 0.0.0');
+}
+
// ─── Server-side rewrite targets ────────────────────────────────────────────
//
// These are the *origin* URLs the Next.js server uses when proxying
@@ -70,6 +86,7 @@ const nextConfig = {
NEXT_PUBLIC_PURPLE_TEAM_API: process.env.NEXT_PUBLIC_PURPLE_TEAM_API || '',
NEXT_PUBLIC_HONEYTOKENS_URL: process.env.NEXT_PUBLIC_HONEYTOKENS_URL || '',
NEXT_PUBLIC_OSQUERY_TLS_URL: process.env.NEXT_PUBLIC_OSQUERY_TLS_URL || '',
+ NEXT_PUBLIC_APP_VERSION: APP_VERSION,
},
// ─── Permanent URL redirects (browser-visible) ───────────────────────────
//
diff --git a/apps/web/src/components/settings/SettingsView.tsx b/apps/web/src/components/settings/SettingsView.tsx
index ebcc2e4d7..be3627b84 100644
--- a/apps/web/src/components/settings/SettingsView.tsx
+++ b/apps/web/src/components/settings/SettingsView.tsx
@@ -28,14 +28,17 @@ import {
ApiError,
connectorsApi,
deploymentApi,
+ tenantsApi,
type AirgapStatus,
type Connector,
type ConnectorStatus,
+ type FullTenant,
type LlmCredentialUpsert,
type LlmCredentialView,
type LlmProvider,
type LlmStatus,
type LlmWritableProvider,
+ type TenantUser,
} from '@/lib/api';
import { Skeleton } from '@/components/ui/Skeleton';
import { ErrorState } from '@/components/ui/ErrorState';
@@ -643,50 +646,108 @@ function ProfilePanel() {
// ─── Panel: Workspace ─────────────────────────────────────────────────────────
function WorkspacePanel() {
+ const {
+ data: tenant,
+ error: tenantError,
+ isLoading: tenantLoading,
+ mutate: retryTenant,
+ } = useSWR<FullTenant>('settings:tenant', () => tenantsApi.getFull(), {
+ revalidateOnFocus: false,
+ shouldRetryOnError: false,
+ });
+
+ const {
+ data: users,
+ error: usersError,
+ isLoading: usersLoading,
+ mutate: retryUsers,
+ } = useSWR<TenantUser[]>('settings:tenant-users', () => tenantsApi.listUsers(), {
+ revalidateOnFocus: false,
+ shouldRetryOnError: false,
+ });
+
+ const activeCount = users?.filter((u) => u.is_active).length ?? 0;
+
return (
<div>
<PanelHeader
title="Workspace"
description="Tenant identity and locale settings. Available to workspace administrators."
/>
- <div className="grid gap-5 px-6 py-5 sm:grid-cols-2">
- <InfoTile label="Workspace name" value="AiSOC Demo" />
- <InfoTile label="Tenant ID" value="tenant_demo_01H0XE4T2WJ9N6" mono />
- <InfoTile label="Plan" value="Open-source (MIT)" />
- <InfoTile label="Region" value="us-east-1 / Multi-AZ" />
- <InfoTile label="Created" value={format(Date.now() - 1000 * 60 * 60 * 24 * 96, 'PPP')} />
- <InfoTile
- label="Default locale"
- value={`${Intl.DateTimeFormat().resolvedOptions().locale} • 24h`}
- />
- </div>
+ {tenantLoading ? (
+ <div className="grid gap-5 px-6 py-5 sm:grid-cols-2">
+ {Array.from({ length: 5 }).map((_, i) => (
+ <Skeleton key={i} className="h-16 w-full rounded-lg" />
+ ))}
+ </div>
+ ) : tenantError || !tenant ? (
+ <div className="px-6 py-5">
+ <ErrorState
+ title="Could not load workspace details"
+ error={tenantError}
+ onRetry={() => retryTenant()}
+ />
+ </div>
+ ) : (
+ <div className="grid gap-5 px-6 py-5 sm:grid-cols-2">
+ <InfoTile label="Workspace name" value={tenant.name} />
+ <InfoTile label="Tenant ID" value={tenant.id} mono />
+ <InfoTile label="Plan" value={tenant.plan} />
+ <InfoTile label="Slug" value={tenant.slug} mono />
+ <InfoTile label="Created" value={format(new Date(tenant.created_at), 'PPP')} />
+ <InfoTile
+ label="Default locale"
+ value={`${Intl.DateTimeFormat().resolvedOptions().locale} • 24h`}
+ />
+ </div>
+ )}
<div className="border-t border-gray-800 px-6 py-5">
<h3 className="text-sm font-semibold text-gray-200">Members</h3>
- <p className="mt-1 text-xs text-gray-500">
- 5 active operators in this workspace (demo data).
- </p>
- <ul className="mt-3 divide-y divide-gray-800 rounded-lg border border-gray-800 bg-gray-950/40">
- {[
- { name: 'Sasha Lin', email: '[email protected]', role: 'Admin' },
- { name: 'Avi Sharma', email: '[email protected]', role: 'Analyst' },
- { name: 'Diego Vega', email: '[email protected]', role: 'Analyst' },
- { name: 'Mia Ocampo', email: '[email protected]', role: 'Hunter' },
- { name: 'CI Service', email: '[email protected]', role: 'Service' },
- ].map((m) => (
- <li
- key={m.email}
- className="flex items-center justify-between px-4 py-3 text-sm"
- >
- <div className="min-w-0">
- <p className="truncate text-gray-100">{m.name}</p>
- <p className="truncate text-xs text-gray-500">{m.email}</p>
- </div>
- <span className="rounded-full bg-gray-800 px-2.5 py-1 text-xs text-gray-300 ring-1 ring-gray-700">
- {m.role}
- </span>
- </li>
- ))}
- </ul>
+ {usersLoading ? null : usersError || !users ? null : (
+ <p className="mt-1 text-xs text-gray-500">
+ {activeCount} active operator{activeCount === 1 ? '' : 's'} in this workspace
+ {users.length !== activeCount ? ` (${users.length} total)` : ''}.
+ </p>
+ )}
+ {usersLoading ? (
+ <div className="mt-3 space-y-2">
+ {Array.from({ length: 3 }).map((_, i) => (
+ <Skeleton key={i} className="h-14 w-full rounded-lg" />
+ ))}
+ </div>
+ ) : usersError || !users ? (
+ <div className="mt-3">
+ <ErrorState
+ title="Could not load members"
+ error={usersError}
+ onRetry={() => retryUsers()}
+ />
+ </div>
+ ) : (
+ <ul className="mt-3 divide-y divide-gray-800 rounded-lg border border-gray-800 bg-gray-950/40">
+ {users.map((u) => (
+ <li
+ key={u.id}
+ className="flex items-center justify-between px-4 py-3 text-sm"
+ >
+ <div className="min-w-0">
+ <p className="truncate text-gray-100">
+ {u.username}
+ {!u.is_active && (
+ <span className="ml-2 rounded-full bg-gray-800 px-2 py-0.5 text-[10px] uppercase tracking-wide text-gray-500 ring-1 ring-gray-700">
+ Inactive
+ </span>
+ )}
+ </p>
+ <p className="truncate text-xs text-gray-500">{u.email}</p>
+ </div>
+ <span className="rounded-full bg-gray-800 px-2.5 py-1 text-xs text-gray-300 ring-1 ring-gray-700">
+ {u.role}
+ </span>
+ </li>
+ ))}
+ </ul>
+ )}
</div>
</div>
);
@@ -2205,8 +2266,8 @@ function AboutPanel() {
description="Open-source SOC platform — community-built, MIT licensed."
/>
<div className="grid gap-4 px-6 py-5 sm:grid-cols-2">
- <InfoTile label="Version" value="v6.0.1" />
- <InfoTile label="Build" value="local • dev" />
+ <InfoTile label="Version" value={`v${process.env.NEXT_PUBLIC_APP_VERSION || '0.0.0'}`} />
+ <InfoTile label="Build" value="Self-hosted • Docker Compose" />
<InfoTile label="License" value="MIT" />
<InfoTile label="Source" value="github.com/beenuar/AiSOC" mono />
</div>
diff --git a/apps/web/src/lib/api.ts b/apps/web/src/lib/api.ts
index fac9ed445..d52d4d3c4 100644
--- a/apps/web/src/lib/api.ts
+++ b/apps/web/src/lib/api.ts
@@ -377,6 +377,34 @@ export interface ChildTenant {
created_at?: string;
}
+// Full tenant record from `GET /api/v1/tenants/me` (requires `settings:read`).
+// See services/api/app/api/v1/endpoints/tenants.py, class TenantResponse.
+export interface FullTenant {
+ id: string;
+ name: string;
+ slug: string;
+ plan: string;
+ is_active: boolean;
+ settings: Record<string, unknown>;
+ limits: Record<string, unknown>;
+ mssp_role?: 'parent' | 'child' | null;
+ parent_tenant_id?: string | null;
+ created_at: string;
+}
+
+// Tenant member from `GET /api/v1/tenants/me/users` (requires `users:read`).
+// See services/api/app/api/v1/endpoints/tenants.py, class UserResponse.
+export interface TenantUser {
+ id: string;
+ tenant_id: string;
+ email: string;
+ username: string;
+ role: string;
+ is_active: boolean;
+ last_login: string | null;
+ created_at: string;
+}
+
export const tenantsApi = {
/**
* Lightweight tenant identity for the SOC console TopBar.
@@ -389,6 +417,16 @@ export const tenantsApi = {
async me(): Promise<MyTenant> {
return request<MyTenant>('/api/v1/tenants/me/identity');
},
+
+ /** Full tenant record (plan, limits, settings) for the Workspace settings panel. */
+ async getFull(): Promise<FullTenant> {
+ return request<FullTenant>('/api/v1/tenants/me');
+ },
+
+ /** All users in the current tenant, for the Workspace settings panel. */
+ async listUsers(): Promise<TenantUser[]> {
+ return request<TenantUser[]>('/api/v1/tenants/me/users');
+ },
};
export const msspApi = {