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.
Python agentic-aiai-securityalert-triageblue-teamcybersecuritydetection-engineeringincident-responselanggraphllm-agentsmcpmitre-attackmodel-context-protocolpurple-teamsecurity-operationsself-hostedsiemsoarsocthreat-detectionthreat-intelligence
fix(auth): complete the OIDC browser flow end to end
Alexandru Mateescuf8b0ba41db7d
diff --git a/apps/web/next.config.js b/apps/web/next.config.jsindex 8fdda3926..0e8e89d1e 100644--- a/apps/web/next.config.js+++ b/apps/web/next.config.js@@ -139,6 +139,13 @@ const nextConfig = {// right downstream service.async rewrites() {return [+ // Identity provider browser flows (/auth/oidc/*, /auth/saml/*). The+ // IdP redirects back to a URL the browser can actually reach; the+ // core API binds to loopback, so the console has to forward these.+ {+ source: '/auth/:path*',+ destination: `${API_HOST}/auth/:path*`,+ },// WebSocket / SSE — realtime gateway.{source: '/ws/:path*',diff --git a/apps/web/src/app/login/page.tsx b/apps/web/src/app/login/page.tsxindex ba738c388..1bb32a0b1 100644--- a/apps/web/src/app/login/page.tsx+++ b/apps/web/src/app/login/page.tsx@@ -66,6 +66,19 @@ function LoginInner() {const [error, setError] = useState<string | null>(null);const [sso, setSso] = useState<{ sso_enabled: boolean; provider: string; login_label: string; local_login_enabled: boolean } | null>(null);+ // An SSO round-trip lands here with the session in the fragment; consume+ // it before the stored-token redirect below can read a still-empty store.+ const [handoffPending] = useState(() =>+ typeof window !== 'undefined' && window.location.hash.includes('access_token='),+ );+ useEffect(() => {+ if (!handoffPending) return;+ authApi.completeSsoHandoff().then((ok) => {+ if (ok) router.replace(next);+ else setError('The SSO sign-in could not be completed. Try again or sign in with your password.');+ });+ }, [handoffPending, next, router]);+useEffect(() => {if (authApi.isAuthenticated()) {router.replace(next);diff --git a/apps/web/src/lib/api.ts b/apps/web/src/lib/api.tsindex 6f75b3dc5..b20358e7e 100644--- a/apps/web/src/lib/api.ts+++ b/apps/web/src/lib/api.ts@@ -526,6 +526,40 @@ export const authApi = {}},+ /**+ * Complete an SSO handoff that the IdP redirected back into the URL+ * fragment (`#access_token=...&refresh_token=...`). Browsers never send+ * fragments to servers, so the tokens appear in no access log or Referer+ * header; this consumes them the moment the login screen mounts, verifies+ * the access token against `/auth/me`, persists the session exactly like+ * a password login would, and scrubs the fragment from history so the+ * tokens do not linger in the address bar or browser session history.+ */+ async completeSsoHandoff(): Promise<boolean> {+ if (typeof window === 'undefined') return false;+ try {+ const hash = window.location.hash;+ if (!hash.includes('access_token=')) return false;+ const params = new URLSearchParams(hash.replace(/^#/, ''));+ const accessToken = params.get('access_token');+ if (!accessToken) return false;+ const refreshToken = params.get('refresh_token') || '';+ window.history.replaceState(null, '', window.location.pathname + window.location.search);+ const res = await fetch(`${API_BASE}/api/v1/auth/me`, {+ headers: { Authorization: `Bearer ${accessToken}` },+ });+ if (!res.ok) return false;+ const user = await res.json();+ persistAuth(+ { access_token: accessToken, refresh_token: refreshToken, token_type: 'bearer', expires_in: 0 },+ user,+ );+ return true;+ } catch {+ return false;+ }+ },+/** Merge user preferences on the server (theme, layout, etc.). */async updateUserPreferences(preferences: Record<string, unknown>): Promise<AuthUser> {const response = await fetch(`${API_BASE}/api/v1/auth/me/preferences`, {diff --git a/docker-compose.yml b/docker-compose.ymlindex afd8fdfae..9903870dc 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -410,6 +410,16 @@ services:# AISOC_SERVICE_TOKEN unreachable to this one service.METRICS_TOKEN: ${METRICS_TOKEN:-}JWT_SECRET: ${JWT_SECRET:-}+ # Enterprise SSO (feature-flagged). Values come from .env; the repo+ # never carries an issuer, client id or secret literal.+ SSO_ENABLED: ${SSO_ENABLED:-false}+ OIDC_ISSUER: ${OIDC_ISSUER:-}+ OIDC_CLIENT_ID: ${OIDC_CLIENT_ID:-}+ OIDC_CLIENT_SECRET: ${OIDC_CLIENT_SECRET:-}+ OIDC_REDIRECT_URI: ${OIDC_REDIRECT_URI:-}+ OIDC_SCOPES: ${OIDC_SCOPES:-openid email profile groups}+ SSO_GROUPS_CLAIM: ${SSO_GROUPS_CLAIM:-}+ SSO_LOGIN_LABEL: ${SSO_LOGIN_LABEL:-Continue with SSO}REALTIME_INTERNAL_TOKEN: ${REALTIME_INTERNAL_TOKEN:-}# The credential this service presents when it proxies the connector# catalog and "Test connection" to the connectors service.diff --git a/services/api/app/auth/oidc.py b/services/api/app/auth/oidc.pyindex 54bc267a0..e1f564d82 100644--- a/services/api/app/auth/oidc.py+++ b/services/api/app/auth/oidc.py@@ -453,7 +453,11 @@ async def oidc_callback(# server and which does not land in an access log or a Referer header,# and the console moves it into the storage its API client reads.separator = "&" if "#" in redirect_url else "#"- response = RedirectResponse(url=f"{redirect_url}{separator}access_token={session['access_token']}", status_code=302)+ response = RedirectResponse(+ url=f"{redirect_url}{separator}access_token={session['access_token']}"+ f"&refresh_token={session['refresh_token']}",+ status_code=302,+ )response.delete_cookie("oidc_state")return response