LangSmith deployments gain multi-tenant auth in ~40 lines of Python
A LangChain video tutorial demonstrates how to add custom multi-tenant authentication to LangSmith agent deployments so each user sees only their own threads, runs, and conversation history.
Score breakdown
Developers shipping multi-user agents on LangSmith can now enforce per-user data isolation and role-based permissions with roughly 40 lines of Python, eliminating the need for custom middleware or separate access-control infrastructure.
- 01LangSmith deployments include 30+ API endpoints covering threads, runs, assistants, cron jobs, a store, and A2A/MCP protocol support.
- 02By default, all endpoints are scoped only to the LangSmith API key, allowing any user to see every other user's threads and conversations.
- 03Custom auth is implemented with two core decorators: `auth.authenticate` (token validation) and `auth.on` (per-user resource scoping).
LangSmith deployments ship with an agent server that exposes 30+ API endpoints covering assistants, threads, runs, cron jobs, stateless executions, a built-in store, and A2A/MCP protocol support. Out of the box, all of these endpoints are locked down only by the LangSmith API key tied to a workspace — meaning any user with that key can read every other user's threads and conversation history. The tutorial demonstrates the problem concretely: a second user signing into a demo app can browse and read threads created by the first user.
The solution involves two custom auth decorators built into LangGraph deployments.
The solution involves two custom auth decorators built into LangGraph deployments. The `auth.authenticate` handler validates incoming tokens against an external auth provider (Supabase is used in the demo, but the pattern works with Auth0, Clerk, or any provider). The `auth.on` handler then automatically scopes all resource access to the authenticated user, so threads, runs, and conversation history are siloed per user by the deployment itself — no custom middleware required. A third decorator enables permission-based access control, such as restricting cron job creation to admin roles only.
The complete auth layer amounts to roughly 40 lines of Python across three decorators. The video walks through local testing, deploying to LangSmith, and a live multi-user demo. The companion repository is available at `https://github.com/langchain-samples/lsd-custom-route-react-ui`.
Key facts
- 01LangSmith deployments include 30+ API endpoints covering threads, runs, assistants, cron jobs, a store, and A2A/MCP protocol support.
- 02By default, all endpoints are scoped only to the LangSmith API key, allowing any user to see every other user's threads and conversations.
- 03Custom auth is implemented with two core decorators: `auth.authenticate` (token validation) and `auth.on` (per-user resource scoping).
- 04The entire auth layer requires approximately 40 lines of Python and three decorators — no custom middleware.
- 05Supabase is used as the auth provider in the demo, but Auth0, Clerk, and other providers are compatible.
- 06Permission-based access control is supported, such as restricting cron job creation to admin roles only.
- 07The companion code repository is at `https://github.com/langchain-samples/lsd-custom-route-react-ui`.