— AI & agents

Permission-aware RAG: keep private answers inside the right account

Design permission-aware RAG for B2B SaaS with retrieval filters, protected citations and cache boundaries. Test access removal, stale indexes and deletion.

3 min readUpdated 2026-10-30By AptixLabs studio
Relevance is not access. Diagram: Identity — Verified caller; Access filter — Current permissions; Retrieval — Allowed documents; Answer — Protected citationsAptixLabs · 2026-10-30

Original AptixLabs workflow diagram; a planning model, not measured product results.

A retrieval-augmented assistant can produce a well-written answer from documents the user was never allowed to see. Relevance is not permission. In B2B SaaS, access control must travel from the source document through indexing, retrieval, answer generation and every cache or citation that exposes the result.

Carry access metadata into the index

Record a stable source identifier, owning workspace, applicable access metadata and source version with each indexed item. Choose how group membership and document permissions are resolved at query time. If the source can change permissions independently, design an update and reconciliation path rather than assuming the first ingestion remains correct forever.

Microsoft's Azure AI Search documentation describes document-level access-control approaches. Supported features and availability vary, so check the selected implementation's current requirements. The architectural requirement remains the same: the application must reliably restrict retrieved material to what the caller may access.

Reference: Azure AI Search document-level access overview

Filter before private material reaches the model

Build retrieval using verified identity and workspace context from the server. Do not accept a browser-provided workspace identifier as sufficient proof. Apply the relevant access constraints before selecting content for generation. Asking the model to ignore unauthorised passages after receiving them is not an access-control mechanism.

Keep the same policy on follow-up queries, tool calls and citations. A citation can leak a document title or URL even when the answer does not quote its contents. Opening that citation should perform an access check instead of trusting that an earlier answer was authorised.

Permission-change evaluation matrix
ScenarioExpected resultCommon hidden path
User from another workspace asksNo private retrieval or answerMissing tenant filter
Group membership is removedRestricted material stops appearingCached authorisation context
Source document is deletedContent is removed under the defined policyStale vectors or answer cache
A shared document becomes privateNew queries respect the changeDelayed ACL update
Old citation is openedCurrent access is checkedUnprotected download URL

Design caches around the security boundary

A response cache keyed only by question text can return one customer's answer to another. Include the scope and policy context necessary to make reuse safe, or avoid sharing answers across users when you cannot establish equivalence. The same issue applies to conversation history: a new workspace selection must not silently inherit private context from a previous workspace.

Deletion needs a defined lifecycle across source content, chunks, indexes and derived caches. Document the expected completion window and what the system does while removal is pending. Where timely permission updates cannot be guaranteed, consider a current source-authorisation check before releasing sensitive results. Avoid promising immediate deletion without evidence from all those stores.

Evaluate security cases alongside answer quality

Create fictional documents with distinct markers for separate workspaces and roles. Ask direct questions, follow-ups and requests that cite hidden titles. Verify retrieved identifiers and outbound content, not just the model's final wording. Repeat after changing permissions and after deletion. A model refusing in one test does not prove that retrieval was correctly scoped.

Related: RAG versus fine-tuning for healthtech products

The reviewed UltraFit360 code provides examples of account-scoped application tools; that is not a claim that every RAG pattern here is deployed in the product. For a knowledge-assistant project, AptixLabs can scope the source inventory, access model and negative evaluation cases before adding a conversational interface. Start with the documents and permission changes the first customer will actually use.

Can a prompt stop RAG from exposing private documents?

A prompt is not a reliable access-control boundary. Restrict retrieval with verified identity and permissions, and protect citations, conversation state and caches as part of the same design.

How should RAG handle deleted documents?

Define removal across the source, chunks, search index and derived caches, with a measurable completion policy. Test queries and old citations after deletion rather than checking only the source file.

Need help with ai agent & automation development?

Tell us about your product, existing stack and the problem you need to solve. We can discuss integration scope, implementation tradeoffs and a practical first milestone.

Start a conversation