Identi PatternsAn initiative of The Identi Exchange

TIE-AGT-018DocumentedAgent identityData access

Permission-aware retrieval for RAG and agent search

Make sure an agent that retrieves documents to answer a question only ever puts content into the model's context that the person it serves, and the agent itself, are allowed to read, using permissions that stay in step with the source systems.

  • EffortHigh
  • Version1.0
  • Reviewed
  • Updated
  • AuthorsTrevonix Innovation

In short#

  • Permissions travel with the content: every chunk in the index carries the access control of its source document, kept in step by sync, and content without permissions is visible to nobody.
  • At query time the agent retrieves as the user: a pre-filter on permission metadata keeps the search fast, and an authoritative check confirms access for sensitive results before they reach the model.
  • Answers, caches, summaries and citations are per user. The agent's own rights are the outer limit; the user's rights decide what each answer may use.

Problem#

A RAG pipeline indexes content from file shares, wikis, ticketing systems and CRM so an agent can find relevant passages and pass them to the model. The indexer usually runs under a service account that can read everything, and the resulting index has no idea who could open which document. When a user asks a question, the agent retrieves the most relevant chunks regardless of who is asking, and the model happily summarises a board paper, a salary file or another customer's contract.

Filtering the answer afterwards does not help: once restricted text is in the model's context it can shape the answer in ways no output filter reliably catches. Permissions also change after indexing; a document shared yesterday and restricted today may still be served from the index.

When to use it#

Use it when

  • An agent or copilot answers questions from content that not every user may read.
  • You build your own RAG pipeline or vector index over enterprise content.
  • Customer-facing agents retrieve from multi-tenant data.
  • Agents retrieve on behalf of users from systems with document- or record-level permissions.

Avoid it, or add more, when

  • All indexed content is genuinely public to every user of the agent. Document that decision and keep restricted content out of that index.

Forces#

  • Speed against accuracy. Filtering on metadata in the index is fast but can lag the source; checking each result against the source of truth is accurate but slower.
  • Coverage against complexity. Real permissions involve groups, inheritance, sharing links and relationships that simple role filters cannot express.
  • Relevance against restriction. Filtering after ranking can leave the agent with too few results; filtering before can be expensive at scale.
  • Shared caches against per-user answers. Caching answers saves cost and leaks across users if keyed wrongly.

Solution#

Treat retrieval as an authorised read. At ingestion, the indexer captures each document's access control (users, groups, roles, sensitivity label, tenant) and writes it as filterable metadata on every chunk; documents it cannot resolve get no access. A sync job keeps permissions current. At query time the agent passes the user's identity, not its own, and the search applies a permission pre-filter. For content above a sensitivity threshold, the agent asks the authoritative authorisation service (or the source system) to confirm each result before it enters the model's context. Everything derived from retrieved content is scoped to the user who asked.

Diagram. Left: source systems (file shares, SharePoint, wiki, CRM) with their permissions. An indexer reads content and permissions; each chunk is stored in the index with metadata: document ID, allowed users and groups, sensitivity label, tenant. A permission sync job keeps metadata current; docume
Permissions travel from source to index; retrieval pre-filters as the user and confirms sensitive results with the source of truth.

Retrieval approaches

ApproachHow it worksStrengthsWeaknesses
Security pre-filterPermission metadata on each chunk; the query filters by the user's IDs and groupsFast; scales; works with rankingLags source changes; group expansion limits
Authoritative post-checkEach candidate result is checked against an authorisation service or the source systemAccurate; handles complex relationshipsSlower; may leave too few results
Federated retrievalThe agent queries source systems with the user's delegated tokenAlways current; source enforces accessSlowest; uneven search quality
Hybrid (recommended)Pre-filter for everything, post-check for sensitive contentBalances speed and accuracyTwo mechanisms to operate

How it works

  1. Capture permissions at ingestion. For each document, record allowed users and groups (or the relationship that grants access), its sensitivity label and its tenant. Copy them to every chunk.
  2. Fail closed. If permissions cannot be resolved, the chunk is visible to nobody until fixed.
  3. Keep in step. Sync permission changes on events where the source supports them, and at least daily; re-index or tombstone deleted and restricted documents promptly.
  4. Search as the user. The agent passes the user's token or identifiers to the search service; the agent's service identity is never used to bypass the filter.
  5. Confirm sensitive results. For results above a threshold, call the authorisation service or source with the user and document ID before using them.
  6. Keep derived data per user. Answer caches, conversation memory, summaries and embeddings of user conversations are keyed and stored per user (and per tenant).
  7. Cite and log. Return citations only for documents the user can open, and log which document IDs fed each answer.

Design rules#

  1. Retrieval is an authorised read, evaluated for the user who asked.
  2. Permissions travel with every chunk.
  3. Unknown permissions mean no access.
  4. The agent's identity is the ceiling, the user's is the filter.
  5. Sensitive content gets an authoritative check before it reaches the model.
  6. Derived data is per user: caches, memory, summaries.
  7. Citations only to documents the user can open.
  8. Log document IDs per answer for investigation.

Anti-patterns#

Anti-patternWhat goes wrong
Index everything under a service account with no ACLsEvery user can get answers from every document
Filter the answer, not the retrievalRestricted text already shaped the answer
Role-only filters for relationship-based sharingSharing links and inheritance are lost; over- or under-sharing
Shared answer cache keyed by question textOne user's answer served to another
Nightly permission sync onlyRevoked access keeps working for a day
Agent searches with its own identityThe user's permissions are ignored entirely

Trade-offs#

Benefits

  • AI answers that respect the same access as the source systems.
  • Safer roll-out of copilots and agents over enterprise content.
  • Evidence of which documents fed which answer.
  • Customer-facing agents that cannot leak one tenant's data to another.

Costs and risks

  • Indexers and sync jobs that understand each source's permission model.
  • Latency for authoritative checks on sensitive content.
  • Authorisation service or relationship store to operate.
  • Remediation of existing oversharing before go-live.

Recipes#

How to build this pattern on specific products. Each recipe shows its own maturity and when it was last verified.

Ping Identity recipe

Ping Identity

PingOne Authorize or PingAuthorize with PingGateway

DocumentedLast verified Nov 2026

Written from vendor documentation and design experience; not yet lab-tested by Trevonix. Validate each step in a non-production tenant first.

Per-document authorisation decisions for sensitive results, with the user's delegated token enforced at the gateway. A Trevonix design from Ping's general capabilities; not lab-tested.

Components

ComponentRole in this pattern
PingOne Authorize or PingAuthorizeEvaluates per-document read decisions for the user and agent
PingGatewayEnforces that retrieval services are called with the user's delegated token
Ping identity platformSupplies the user's identity, groups and attributes

Configure

  1. Store permission metadata on chunks as described above for the pre-filter.
  2. For sensitive results, have the retrieval service send a batch of document IDs with the user and agent to your authorisation policy and keep only permitted documents.
  3. Front the retrieval service with PingGateway so it receives the user's delegated token, not just the agent's.

Okta recipe

Okta

Auth0 Fine-Grained Authorization with Okta or Auth0 identities

DocumentedLast verified Nov 2026

Written from vendor documentation and design experience; not yet lab-tested by Trevonix. Validate each step in a non-production tenant first.

Relationship-based checks on each retrieved document through the Auth0 AI SDK retriever filters. Written from Auth0 documentation; not lab-tested by Trevonix.

Components

ComponentRole in this pattern
Okta or Auth0 user identityThe user the agent retrieves for
Auth0 Fine-Grained Authorization (FGA)Stores relationships between users, groups and documents and answers "can this user view this document?"
Auth0 AI SDKsProvide retriever filters for LangChain, LlamaIndex and similar frameworks

Configure

  1. Model documents and their relationships in FGA (for example owner and viewer relations on a doc type, with group membership) and write tuples as documents are created and shared.
  2. In the agent's retriever, wrap the vector search with the SDK's FGA filter so every candidate document is checked for the current user before it is returned.
  3. Keep FGA tuples current from the source systems' sharing events.
  4. Use a pre-filter on tenant or broad group in the vector store to keep candidate sets small, then let FGA make the final decision.

Microsoft Entra recipe

Microsoft Entra

Azure AI Search document-level access control with Microsoft Entra ID

DocumentedLast verified Nov 2026

Written from vendor documentation and design experience; not yet lab-tested by Trevonix. Validate each step in a non-production tenant first.

Permission metadata ingested with content and enforced at query time from the user's Entra token; security filters for other sources. Written from Microsoft documentation; not lab-tested by Trevonix.

Components

ComponentRole in this pattern
Azure AI Search document-level access controlACL and RBAC permission metadata on indexed documents, enforced at query time from the user's Entra token
SharePoint and ADLS Gen2 indexersIngest source permissions with the content (preview)
Microsoft Purview sensitivity labelsClassify content so sensitive results can get extra checks
Entra IDIssues the user token the search service uses to trim results

Configure

  1. Create the index with permission filter fields (user IDs and group IDs as Entra object IDs, or RBAC scope) and enable the permission filter option, using the preview REST API version that supports it.
  2. Use the ADLS Gen2 or SharePoint indexer to ingest permission metadata with the content, or push ACLs with the push API for custom sources.
  3. At query time, have the agent pass the user's Entra token in the x-ms-query-source-authorization header so the service trims results to what the user can read.
  4. For sources without native support, use security filters: store allowed user and group IDs in a filterable string field and add a filter for the user's IDs to every query.
  5. Use sensitivity labels to route confidential results to an extra check, and review oversharing before roll-out.

Gotchas

  • Permission metadata is evaluated as last synced; changes in the source are not enforced until the indexer runs again.
  • Documents with more ACL entries than the documented limits may not be fully enforced.
  • Native ACL and RBAC enforcement is in preview APIs; check feature availability in your region and API version.

Saviynt recipe

Saviynt

Saviynt access governance and Agent Access Gateway

DocumentedLast verified Nov 2026

Written from vendor documentation and design experience; not yet lab-tested by Trevonix. Validate each step in a non-production tenant first.

Reduces source oversharing and limits which knowledge bases each agent can reach; per-document enforcement stays in the retrieval layer. Written from Saviynt's published material; not lab-tested by Trevonix.

Capabilities used

CapabilityRole in this pattern
Access governance and certificationReviews and reduces who has access to the source repositories the index reads
Agent Access GatewayControls which knowledge bases and tools an agent may reach

Configure

  1. Certify and clean up access to the repositories that feed RAG indexes before roll-out.
  2. Restrict each agent's outbound access to the knowledge bases its purpose requires.
  3. Keep per-document enforcement in the retrieval layer as described above.

OpenFGA, Elasticsearch document-level security or PostgreSQL row-level security recipe

OpenFGA, Elasticsearch document-level security or PostgreSQL row-level security

DocumentedLast verified Nov 2026

Written from vendor documentation and design experience; not yet lab-tested by Trevonix. Validate each step in a non-production tenant first.

Open-source and database-native options for permission-aware retrieval.

OpenFGA (the open-source project behind Auth0 FGA) provides relationship-based checks for any stack. Search engines such as Elasticsearch and OpenSearch offer document-level security, and PostgreSQL row-level security can enforce permissions on pgvector tables when queries run as the user's role.

Verification tests#

TestExpected result
User A asks about a document only user B can readNot retrieved; not cited; answer does not use it
Remove a user's access in the sourceDocument no longer retrieved within the sync target
Index a document with unresolvable permissionsVisible to nobody
Two users ask the same questionAnswers built from each user's permitted documents; no cache crossover
Customer agent for tenant X searchesNever retrieves tenant Y content
Confidential result returned by the pre-filter for a user who lost accessRejected by the authoritative check

Maturity and verification#

Documented. This pattern is written from vendor and project documentation and has not yet been lab-tested by Trevonix.

Frequently asked questions#

Whose permissions apply: the agent's or the user's?

Both, in different roles. The agent's own access decides what it can ever retrieve. The user's access decides what it may use for this user's answer. Retrieval must pass both.

Are embeddings sensitive?

Embeddings are derived from the text and can leak information about it. Store them in the same index with the same permission metadata as the chunk, and never share an embedding store across tenants without filtering.

Does Microsoft 365 Copilot already do this?

Copilots built on platform search generally respect the source permissions. That makes existing oversharing visible, so fixing broad sharing and applying sensitivity labels is still your job before roll-out.

Related patterns and references#

Cite this pattern

Trevonix (2026). Permission-aware retrieval for RAG and agent search (TIE-AGT-018, version 1.0). Identi Patterns. https://exchange.trevonix.com/patterns/tie-agt-018-permission-aware-retrieval-for-rag-and-agent-search

Licensed under CC BY 4.0. Credit Trevonix and link to this page when you reuse it.

Patterns are guidance, provided as is and without warranty. Test in a non-production environment and check current vendor documentation before you rely on them. Read the full disclaimer.