ข้ามไปยังเนื้อหา

Identity, Access, and Data Isolation

  • Every request path must resolve to an authenticated user identity.
  • Project and thread scope must stay consistent end to end.
  • Service-to-service calls must not rely on browser user bearer forwarding.
  • Tool side effects must run with explicit scope context.
  • UI thread/message operations currently use Supabase client SDK directly.
  • Scope protection depends on user auth plus DB policy constraints.
  • Thread/project/team checks are also enforced in chat service methods.
  • /api/ai/* and /api/canvas/* require authenticated user token.
  • BFF resolves trusted user scope and blocks cross-user or cross-project thread access.
  • BFF request and metadata allowlists prevent schema drift from client payloads.
  • Validates internal contract headers (X-Contract-Version, X-User-Id, etc.).
  • Optionally validates internal bearer token (INTERNAL_ENGINE_TOKEN).
  • Rejects header/body claim mismatches with 403.
  • authenticateRequest validates userId and thread ownership when thread is present.
  • Scope gating and phase gating restrict tool usage by agent and workflow phase.
  • Mutation tools require approved execution context plus scoped identifiers.
Scope ObjectSource of TruthEnforcement Layer
user_idSupabase auth userBFF auth, engine contract, MCP auth
project_idThread/project data modelBFF scope checks, engine header/body checks, MCP context
thread_idkobi_chat_threads.idUI creation flow, BFF normalization, engine checks, MCP ownership check
team_idkobi_project_teamsChat service team scope checks
sequenceDiagram
  participant UI as Browser
  participant BFF as kobi-ai
  participant ENG as kobi-agent-service
  participant MCP as kobi-mcp-server

  UI->>BFF: Bearer user token + chat payload
  BFF->>BFF: verify user and scope
  BFF->>ENG: internal headers + normalized body
  ENG->>ENG: validate internal contract
  ENG->>MCP: tool call with approved + scoped IDs
  MCP->>MCP: auth + gate + mutation checks

If any layer cannot prove user/project/thread alignment, request execution should stop with 400/403 rather than continue with partial trust.