TIE-AGT-018DocumentedAgent identity/Data 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.
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.

Retrieval approaches
| Approach | How it works | Strengths | Weaknesses |
|---|---|---|---|
| Security pre-filter | Permission metadata on each chunk; the query filters by the user's IDs and groups | Fast; scales; works with ranking | Lags source changes; group expansion limits |
| Authoritative post-check | Each candidate result is checked against an authorisation service or the source system | Accurate; handles complex relationships | Slower; may leave too few results |
| Federated retrieval | The agent queries source systems with the user's delegated token | Always current; source enforces access | Slowest; uneven search quality |
| Hybrid (recommended) | Pre-filter for everything, post-check for sensitive content | Balances speed and accuracy | Two mechanisms to operate |
How it works
- 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.
- Fail closed. If permissions cannot be resolved, the chunk is visible to nobody until fixed.
- 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.
- 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.
- Confirm sensitive results. For results above a threshold, call the authorisation service or source with the user and document ID before using them.
- Keep derived data per user. Answer caches, conversation memory, summaries and embeddings of user conversations are keyed and stored per user (and per tenant).
- Cite and log. Return citations only for documents the user can open, and log which document IDs fed each answer.
Design rules#
- Retrieval is an authorised read, evaluated for the user who asked.
- Permissions travel with every chunk.
- Unknown permissions mean no access.
- The agent's identity is the ceiling, the user's is the filter.
- Sensitive content gets an authoritative check before it reaches the model.
- Derived data is per user: caches, memory, summaries.
- Citations only to documents the user can open.
- Log document IDs per answer for investigation.
Anti-patterns#
| Anti-pattern | What goes wrong |
|---|---|
| Index everything under a service account with no ACLs | Every user can get answers from every document |
| Filter the answer, not the retrieval | Restricted text already shaped the answer |
| Role-only filters for relationship-based sharing | Sharing links and inheritance are lost; over- or under-sharing |
| Shared answer cache keyed by question text | One user's answer served to another |
| Nightly permission sync only | Revoked access keeps working for a day |
| Agent searches with its own identity | The 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
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
| Component | Role in this pattern |
|---|---|
| PingOne Authorize or PingAuthorize | Evaluates per-document read decisions for the user and agent |
| PingGateway | Enforces that retrieval services are called with the user's delegated token |
| Ping identity platform | Supplies the user's identity, groups and attributes |
Configure
- Store permission metadata on chunks as described above for the pre-filter.
- 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.
- 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
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
| Component | Role in this pattern |
|---|---|
| Okta or Auth0 user identity | The 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 SDKs | Provide retriever filters for LangChain, LlamaIndex and similar frameworks |
Configure
- Model documents and their relationships in FGA (for example
ownerandviewerrelations on adoctype, with group membership) and write tuples as documents are created and shared. - 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.
- Keep FGA tuples current from the source systems' sharing events.
- 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
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
| Component | Role in this pattern |
|---|---|
| Azure AI Search document-level access control | ACL and RBAC permission metadata on indexed documents, enforced at query time from the user's Entra token |
| SharePoint and ADLS Gen2 indexers | Ingest source permissions with the content (preview) |
| Microsoft Purview sensitivity labels | Classify content so sensitive results can get extra checks |
| Entra ID | Issues the user token the search service uses to trim results |
Configure
- 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.
- Use the ADLS Gen2 or SharePoint indexer to ingest permission metadata with the content, or push ACLs with the push API for custom sources.
- At query time, have the agent pass the user's Entra token in the
x-ms-query-source-authorizationheader so the service trims results to what the user can read. - 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.
- 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
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
| Capability | Role in this pattern |
|---|---|
| Access governance and certification | Reviews and reduces who has access to the source repositories the index reads |
| Agent Access Gateway | Controls which knowledge bases and tools an agent may reach |
Configure
- Certify and clean up access to the repositories that feed RAG indexes before roll-out.
- Restrict each agent's outbound access to the knowledge bases its purpose requires.
- 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
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#
| Test | Expected result |
|---|---|
| User A asks about a document only user B can read | Not retrieved; not cited; answer does not use it |
| Remove a user's access in the source | Document no longer retrieved within the sync target |
| Index a document with unresolvable permissions | Visible to nobody |
| Two users ask the same question | Answers built from each user's permitted documents; no cache crossover |
| Customer agent for tenant X searches | Never retrieves tenant Y content |
| Confidential result returned by the pre-filter for a user who lost access | Rejected 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.