Talk

Chatting with Data, Safely: Role-Based Authorization for Text-to-SQL Agents

Thursday, May 28

11:45 - 12:15
RoomSpaghetti
LanguageEnglish
Audience levelIntermediate
Elevator pitch

Text-to-SQL agents can query anything — but should they? When users have different roles and data permissions, guardrails matter. Discover how to decouple AI agent logic from authorization policies using open-source tools, without slowing down your chat-to-data experience.

Abstract

Text-to-SQL agents can query anything — but should they? When AI agents turn natural language into executable SQL, traditional data-access guardrails are easy to bypass. The challenge becomes critical when real users, with real roles and permissions, are the ones chatting with your data.

In this talk, we explore how to decouple AI agent logic from authorization policies without sacrificing flexibility or performance. Starting from the real-world challenges of Text-to-SQL in agentic platforms, we ask: how can we ensure users see exactly the same data—no more, no less—whether they access it through a UI or via an AI agent?

We’ll present a production-ready solution combining:

  • a Python package that inspects and rewrites the SQL Abstract Syntax Tree (AST), and
  • partial evaluation results from Open Policy Agent (OPA) to enforce fine-grained authorization at query time.

This approach keeps authorization logic centralized, auditable, and independent from LLM prompts, while integrating seamlessly with Text-to-SQL tools.

You’ll leave with a concrete architectural pattern, open-source building blocks, and practical lessons on how to safely scale AI agents—without turning your LLM into a superuser.

TagsSecurity, ML and AI
Participant

Marco Santoni

Marco Santoni is a Data Platform and Engineering Manager at TeamSystem, where he works on scalable data platforms, AI-enabled data products, and data governance architectures. Based in Milan, he is an active member of Python Milano community and co-host of the Intervista Pythonista podcast. He is also involved in education as Technical and Scientific Advisor at ITS Rizzoli, where he teaches data and software engineering topics.