A step-by-step tutorial shows how to build a RAG-based expense report agent using Microsoft Agent Framework in .NET, storing embeddings with CommunityToolkit.VectorData.InMemory and OpenAI's text-embedding-3-small model. It then secures the retrieval pipeline with Auth0 Fine-Grained Authorization (FGA), fetching a manager's authorized expense IDs before running the vector search so unauthorized records never reach the LLM. The tutorial walks through setting up the FGA store, defining an authorization model, writing permission tuples, and wiring an FgaService into the agent's tools and Blazor chat component, demonstrating that different managers see only their own direct reports' expenses.

15m read timeFrom auth0.com
Post cover image
Table of contents
Adding the Vector Store PackageThe Expense Report ModelThe Expense Report ServiceUpdating the Search ToolThe Expense Service in the Chat ComponentRegistering the Expense ServiceEveryone Sees Everything (For Now)Setting Up Auth0 FGAThe FGA ServiceUpdating the Expense Report ServiceAdding FGA to the Search ToolThe FGA Service in the Chat ComponentRegistering the FGA ServiceTesting the AuthorizationWhere This Leaves Us

Questions this post answers

How do I prevent a RAG-based LLM agent from seeing data a user isn't authorized to access?

Filter the vector search results using an authorization check before the search runs, not after. Query the authorization system (such as Auth0 FGA's ListObjects call) for the list of object IDs the user can read, then pass that allow-list as a filter into the vector store query. This ensures the LLM only ever receives context the user is permitted to see, rather than retrieving everything and filtering the final answer. Track patterns like FGA-filtered RAG pipelines as you design agent authorization on daily.dev.

What embedding dimension size does OpenAI's text-embedding-3-small model produce for a vector store schema?

OpenAI's text-embedding-3-small model outputs 1536-dimensional embeddings. When defining a vector store field with Microsoft.Extensions.VectorData's [VectorStoreVector] attribute, the dimensions parameter must be set to 1536 with a distance function such as CosineSimilarity to match this model's output correctly. daily.dev helps developers pin down exact embedding config details before wiring up vector stores.

How does Auth0 FGA's ListObjects API work for filtering authorization results?

ListObjects evaluates the authorization model and returns every object of a given type that a user can reach via a specified relation, covering not just direct tuples like user:X can_read expense:Y but also indirect paths such as manager groups added later. Calling it with a user and relation (e.g., can_read on type expense) returns the complete set of accessible object IDs, which can then pre-filter a search. Developers building agent permission models can follow FGA usage patterns like this via daily.dev.

2.7K Impressions