Design permission-aware RAG
Design RAG access controls around source permissions, stale indexes and revocation, with a synthetic negative-test corpus and explicit failure behavior.
Last updated
In short
- Apply document authorization before content enters the model context.
- Index metadata must carry a permission version and deletion state.
- Revocation tests must cover cached answers and old conversations.
On this page (6)
Architectures · Part of Private AI
Editable scenarios for access, revocation, cache and recovery checks.
Download the synthetic permission testsTreat retrieval as an authorization operation
Permission-aware retrieval-augmented generation means that every document fragment admitted to a model request is authorized for the current user and purpose. A login screen and a shared vector collection do not establish that property. Neither does a prompt instructing the model to keep information confidential after restricted content has already entered its context.
The following is a reference architecture and a synthetic test specification. It has not been executed as a laboratory result. It describes the evidence an implementation should produce before a restricted corpus becomes available through private AI.
Separate the identity, policy and retrieval boundaries
A defensible request path is: authenticate the person, resolve current entitlements, retrieve candidate identifiers, authorize those identifiers, fetch permitted text, then construct the model context. Depending on the implementation, filtering can happen during candidate retrieval as well as during final authorization. The crucial requirement is that an unauthorized candidate never becomes model-visible text.
| Boundary | Trusted input | Reject when |
|---|---|---|
| Authentication | Validated issuer, subject, audience and session | Token expired, issuer unexpected or account disabled |
| Policy service | Current document ACL and group memberships | Policy unavailable or entitlement revision unknown |
| Vector lookup | Server-generated tenant and ACL filter | Browser supplies unrestricted collection or filter |
| Content fetch | Authorized document ID and revision | Revision differs from the authorized version |
| Answer construction | Authorized chunks and citation IDs | A chunk has no verifiable source or access decision |
| Conversation replay | Current authorization for referenced sources | A historical turn contains now-revoked material |
Qdrant provides payload filtering, which can constrain candidate selection. That capability does not automatically synchronize a document system’s permissions. The application remains responsible for trustworthy metadata, filter construction and any required source-system recheck. The Qdrant security guide is a separate concern: protect database access so clients cannot bypass the application policy layer.
Store provenance alongside the vector
A useful chunk record contains a stable source document ID, source revision, tenant ID, chunk ordinal, content digest, ACL revision and indexing timestamp. The permission policy should reference immutable subject or group identifiers. Display names and email addresses are unsuitable as the only durable keys because they can change or be reused.
For a simple departmental corpus, groups might be engineering and finance. A document can be available to engineering, finance, both or neither. Avoid interpreting a missing permissions field as public access. Missing, malformed or stale permission metadata should exclude the document until it can be reconciled.
Identity-provider groups can supply part of the entitlement model, but they do not necessarily describe document-level exceptions. Review Keycloak’s role and group model when designing claims. A token issued before a group removal can remain valid; token lifetime is not a replacement for a defined revocation mechanism.
Use a deliberately adversarial synthetic corpus
Create four harmless documents with unique marker phrases that cannot be guessed from general knowledge. Keep the phrases synthetic so a failed test does not expose real information.
| Document | Allowed accounts | Synthetic marker | Expected negative check |
|---|---|---|---|
| General handbook | Alice and Bob | violet-lantern-41 | Anonymous account sees no content |
| Engineering plan | Alice | copper-orbit-62 | Bob cannot retrieve, summarize or cite it |
| Finance forecast | Bob | silver-garden-73 | Alice cannot retrieve it through semantic paraphrase |
| Withdrawn draft | Nobody | amber-river-84 | No account receives it after deletion reconciliation |
Ask direct questions, paraphrases and broad summaries. Try a forged document ID, a changed tenant parameter and a prompt asking the model to ignore access rules. Record candidate IDs, authorized IDs and citation IDs separately; a safe final answer alone does not prove the model never saw restricted material.
Test revocation across time
Start Alice with engineering access and let her retrieve the engineering plan. Remove access in the source of truth while retaining her existing browser session. Repeat the request immediately and after the agreed propagation interval. Then reopen the old conversation, regenerate the answer, export the chat and request the cited source directly.
Set a maximum revocation delay that the business owner can accept. If current policy cannot be checked and cached entitlements have exceeded that limit, deny the affected retrieval. Make this a visible service condition with an operational alert, not a silent fallback to the full index.
Deletion has several destinations: source text, extracted chunks, vectors, answer caches, conversation history and backups. They may follow different approved retention policies. A source deletion should at least stop future retrieval at once through a tombstone or equivalent denial mechanism, even when physical cleanup takes longer.
Version and recovery checks
Pin the embedding model, vector dimensions, database/client releases and authorization implementation. An embedding-model change generally requires a planned reindex; a policy-schema change requires migration of every existing chunk. Test mixed-version behavior before rolling components independently.
Back up configuration and policy mappings alongside the vector data. A restored index may contain permissions or documents that have since been revoked. Restore into an isolated network, replay deletion and permission changes, then run the negative corpus before enabling traffic. Success means the authorized account receives the correct source, every denied case remains denied, and the evidence identifies which component made each decision. No finite test suite establishes a universal guarantee against information leakage.
Sources and further reading
Use the linked documentation to confirm the version, edition and contract that apply to your project.
