No service accounts

Every AI question runs as the employee who asked it

Langdock to Snowflake Cortex Agents with per-user Entra ID identity, row access and audit.

Kevin Keller ยท kevinkeller.org

Why it matters

One technical account means the AI sees everything

  • The quick way to connect a chat tool to a warehouse is one shared account
  • Fund and department permissions disappear
  • The audit trail says "the bot did it"
  • In a firm under BaFin and DORA, that is a non-starter

The approach

Pass the employee's own identity through

  1. The employee signs in to Langdock with Entra ID SSO
  2. Langdock gets a per-user token via OAuth Authorization Code + PKCE
  3. The token goes as the Bearer to Snowflake's managed MCP server
  4. External OAuth accepts only the organisation's Entra tenant
  5. The session runs as the employee with one role, MCP_USER

One role, per-user data

Policies on the user, not on the role

  • Every user gets the same least-privileged MCP role
  • Row access policies check CURRENT_USER() against an entitlement table
  • Masking policies apply in the same session
  • An Equity analyst sees Equity funds in SQL, a dashboard or a chat

What it delivers

Same permissions in the AI as in the warehouse

  • A named person behind every query in query and access history
  • No stored credentials: revoke the user in Entra and access stops
  • Silent connect: admin consent makes it one redirect
  • Audit answers: agent inventory, sensitive reads, usage and errors from system views

The biggest design decision

Cortex Search is not filtered per user

A search service runs with its owner's rights. Split unstructured content into one service per access domain, or the agent becomes a side channel around row access.

Two more things that bite

Shared agents and failover need care

  • Pre-selected connections: a shared agent then runs as its owner, so for regulated data the answer is usually no
  • MCP servers don't replicate with failover groups
  • A scheduled task recreates them on the secondary with Entra client credentials, no stored secret

Dashboard warning

A failed tool still reports SUCCESS

Error rates must count a non-success status or warnings, or a broken agent looks healthy.

When a semantic view was dropped, the request stayed SUCCESS and the failure appeared only as warning 399569.

What was tested

The identity flow holds end to end

CheckResult
Calls carry the employee's own tokenPassed
Query returned only their fundPassed
Token refresh without new sign-inPassed
Shared agent with owner connectionRan as owner
Cortex Search on non-entitled fundLeaked, split services

Takeaway

The employee's token goes in, their permissions apply, their name goes in the audit trail.

Read the full article

Personal project, not an official Snowflake or Langdock product