Agent skill · security · jeremylongshore
langchain-enterprise-rbac
Enforce tenant isolation and role-based access across LangChain 1.0\
Why this skill is useful
Adds executable scripts for tenant isolation and role-based access control that fundamentally enhance security in multi-tenant SaaS applications.
What it needs
Requires chromadb, langchain-core, langchain-postgres, langgraph, pinecone-client, python installed locally. About 8k tokens when loaded. Last updated 2026-08-07. 2,604 stars on the source repository.
What this skill does
LangChain Enterprise RBAC (Python) Overview A B2B SaaS team shipped their first RAG feature for two tenants. The factory code looked innocent: build PineconeVectorStore once at module import with namespace="acme-corp" (the first tenant), convert it to a retriever, store it in a module global, reuse on every request. Six weeks later tenant "Initech" went live. Their first search returned three documents from Acme Corp. The singleton retriever had captured the Acme namespace at process start. RunnableConfig.configurable["tenantid"] was being passed in — but the retriever never read it, because the filter was baked in. Every request for every tenant hit the same Pinecone namespace. Security review caught it three days later and put a hold on the SOC2 renewal. This is pain-catalog entry P33, the single most common cause of cross-tenant leak in LangChain 1.0 production. This skill fixes it with four workstreams: P33 — retriever-per-request factory — build the retriever inside the chain or agent invocation, keyed by tenantid from RunnableConfig. Never at module scope. Unit-test with two tenants and assert non-overlap. Role-scoped tool allowlist — build the agent per-request with only the tools the current user's role permits. Forbidden tools are not passed to createagent at all, so the model cannot call them even if it tries. Per-tenant rate limit + budget — scope the InMemoryRateLimiter (or a Redis-backed equivalent) by tenantid, and check a per-tenant USD budget before invoking the model. Structured audit log — JSON log with userid, tenantid, chainname, toolscalled, costusd, outcome, emitted in both success and failure paths. Ships to SIEM or BigQuery. Two failure patterns anchor this skill: import-time retriever binding (P33) and missing audit log on tool failure (the try block logs on success but the except branch re-raises without emitting, so incident response has no record of denied tool calls). …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills jeremylongshore/langchain-enterprise-rbac--0bff7e