Integrations
LangChain and LangGraph
Authorize LangChain tools and LangGraph tool nodes with identity from the injected run config.
LangChain tools can declare a config: RunnableConfig parameter. LangChain injects it at run time and hides it from
the model, which makes it the right place for verified identity.
Python
import os
from langchain_core.runnables import RunnableConfig
from langchain_core.tools import tool
from reqlo import Reqlo, ReqloDeniedError
reqlo = Reqlo(api_key=os.environ["REQLO_API_KEY"])
@tool
def read_document(document_id: str, config: RunnableConfig) -> str:
"""Read a workspace document by ID."""
identity = config["configurable"] # set by your server when invoking the graph
doc = documents.get(document_id)
try:
reqlo.enforce(
agent={"id": identity["agent_id"]},
subject={"id": identity["user_id"], "kind": "user"},
action="documents.read",
resource={"type": "document", "id": doc.id, "attributes": {"owner_id": doc.owner_id}},
context={"document_classification": doc.classification},
)
except ReqloDeniedError:
return "You don't have access to that document."
return doc.contentLangGraph
Use the protected tools in a ToolNode or a prebuilt agent, and pass identity in configurable when you invoke the
graph from your server:
Python
from langgraph.prebuilt import create_react_agent
graph = create_react_agent(model, tools=[read_document])
result = graph.invoke(
{"messages": [("user", request.message)]},
config={"configurable": {"user_id": session.user_id, "agent_id": "agt_assistant_42"}},
)Execution boundary
The check runs inside the tool function, so every path that executes the tool (ReAct loops, parallel tool calls, retries) is covered. Graph nodes that cause side effects without being tools need their own check.
Something wrong or unclear? Report an issue with this page.