Back
Kevin Riedl

14 min read · 11 Jun 2026
Last reviewed

Next
Made on your device, with no Instagram connection. We copy the post link for Instagram’s Link sticker.

RAG over SharePoint, Confluence, and Google Drive: Permissions-First Architecture

The hard problem in enterprise RAG is permissions: the assistant must never surface a document to someone who is not allowed to see it. An embedding does not carry or enforce the source authorization by itself, so a naive "embed everything, retrieve top-k" pipeline matches on similarity, not access. Enforce authorization before generation: attach source-native access context to every chunk, or maintain an authoritative lookup, and apply a mandatory filter or live authorization decision before any result reaches the model. Preserve each source's rules for direct users, groups, domains, links, inheritance, and protection instead of reducing them to a universal group-only or deny-wins model.

This is the implementation companion to our RAG production-readiness checklist, which names per-user permissions as the hard security problem. This post is how you actually solve it. Vendor-specific and preview features move fast; re-check the linked docs before you build.

Building a RAG assistant over your document stores?

 Book Free Consultation

Why permissions are the hard part

The failure mode is simple: the model composes a fluent answer from a document the asking user was never allowed to see. Chunking and embedding do not automatically copy the source system's effective authorization into a shared index. A vector store only knows the caller and their entitlements if the retrieval system supplies and enforces them.

Microsoft says Microsoft 365 Copilot only accesses data the signed-in user is authorized to access and respects SharePoint controls and sensitivity-label encryption. It can nevertheless make existing oversharing easier to discover. Microsoft therefore offers governance controls such as Restricted Content Discovery, a temporary SharePoint control with documented scope limits, and Data Access Governance reports. These controls reduce discovery or help remediate permissions; they do not replace correct source permissions. (1, 2)

Telling the model not to reveal a document is not access control. The current OWASP LLM Top 10 lists prompt injection as LLM01, and NIST documents indirect prompt injection arriving through retrieved content. Authorization must be enforced by trusted application or data-layer logic before untrusted content reaches the model. (3)

The principle: enforce at the retrieval layer

The model must never process an unauthorized chunk. Prefer authorization-aware pre-filtering inside a trusted retrieval service. A two-stage design can over-fetch candidates and authorize them before they leave that service, but it must continue searching until it has enough authorized results and must never place rejected content in model context, logs, or client responses. Filtering in the prompt is not enforcement.

Per-source permission models

Each source has different principals, inheritance, sharing links, and protection controls. Use a dedicated connector identity with the least privileges and repository scope needed for the approved corpus. Normalize fields for retrieval efficiency, but retain enough source-native facts to reproduce the source's effective authorization.

SourceHow permissions workThe trap to handle
SharePoint / OneDrive (Microsoft Graph)DriveItem permissions can be direct or inherited; use inheritedFrom and the grantedToV2 family of fieldsGraph sharing permissions are only part of the decision. Site membership, sharing links, broken inheritance, and sensitivity-label encryption can also affect access. (4)
Confluence CloudViewing requires product and space access plus every applicable page restriction; view restrictions inherit to descendantsA direct restriction response does not prove effective access. Evaluate restricted ancestors too. Public links can expose content outside normal access restrictions and need an explicit policy. (5)
Google DrivePermission types include user, group, domain, and anyone; roles include owner, organizer, fileOrganizer, writer, commenter, and readerPermissions normally propagate down. A directly granted child role can increase access, while limited-access folders can restrict inherited access, so do not assume shared-drive access is always expansive. (6)

For Microsoft Graph, code against grantedToV2 and grantedToIdentitiesV2; the older fields are deprecated. Choose the least-privileged delegated or application permissions that fit the connector, and prefer resource-scoped approaches such as selected-site access over tenant-wide read access when feasible. (4)

Implementation patterns that hold up

  • Store stable source-native principals. Groups reduce cardinality, but direct user grants, domain and anyone links, inherited restrictions, and protected-content state can also decide access. Resolve nested memberships where the source supports them.
  • Bind every query to the signed-in subject. Use immutable subject and tenant identifiers, then resolve effective entitlements or ask the source. Microsoft's OAuth on-behalf-of flow carries a user's delegated permissions, not application roles; Google and Atlassian require their own delegation or authorization designs. (8)
  • Make authorization mandatory in retrieval. Use set-membership filters where the source semantics are additive, and explicit checks for ancestor restrictions, limited access, links, and encryption. There is no safe universal "deny overrides grant" rule across these products.
  • Handle Entra group overage. Microsoft documents a 200-group limit for JWT group claims and 150 for SAML. Above the limit, the token omits the group list and supplies an overage indicator, so the application must obtain the full membership set before authorizing. (7)
  • PostgreSQL row-level security can enforce the predicate near pgvector data, but it is not impossible to bypass. Superusers and roles with BYPASSRLS always bypass it; table owners normally do too unless FORCE ROW LEVEL SECURITY applies. Keep application roles unprivileged, test policy composition, and set request identity transaction-locally in pooled connections. (9)

There is a real architecture trade-off. A synchronized authorization index gives predictable retrieval latency but creates a revocation window. A live source check offers fresher decisions but adds dependency latency and availability risk. Many systems combine both: pre-filter with synchronized metadata, re-check sensitive results live, and fail closed whenever authorization state is stale or unavailable.

The freshness problem nobody budgets for

When permissions are materialized at ingest, a source-side revocation is not automatically reflected in the index. Change feeds are useful signals, not proof that every descendant's effective access was recomputed. Google documents that ACL changes appear in a user's change log only for owners, service accounts on the ACL, or directly affected users; shared-drive connectors should use the shared-drive change log where applicable. Combine incremental events with periodic reconciliation of ancestor-dependent authorization and a fail-closed freshness threshold. (10)

Deletion is the other half. Where a GDPR erasure obligation applies, and derived chunks, embeddings, caches, or logs remain personal data, delete or anonymize those artifacts subject to the regulation's grounds and exceptions. Stable document-to-chunk lineage makes this practical. Embeddings are not categorically personal data, but they can be when they relate to an identifiable person. One published attack recovered 92% of 32-token inputs exactly in a specific white-box setup against two embedding models; that result shows a real confidentiality risk, not a universal recovery rate. (11, 12)

GDPR and residency

GDPR data minimization and storage limitation support limiting the indexed corpus and retaining derived artifacts only as long as needed. Retrieval audit logs can support accountability and incident investigation, but the logs themselves may contain personal data, so minimize, protect, and expire them. If a model provider acts as a processor, Article 28 requires appropriate contractual terms; Chapter V governs transfers to third countries. An EU inference endpoint alone does not prove that all processing, storage, support access, and subprocessors stay in the EU, so verify the full data flow and contract. See EU data residency for AI apps in 2026. (11)

The reference architecture, and the anti-patterns

End to end: scope a least-privileged connector to the approved repositories; capture each item's source-native principals, inheritance, links, and protection state; attach a versioned authorization reference or filterable projection to every chunk; bind retrieval to the signed-in subject; authorize before model context; log a minimized decision record; reconcile change feeds with periodic effective-access sweeps; and cascade applicable deletions through derived artifacts.

Anti-patterns include a shared index with no mandatory authorization; prompt-only filtering; querying as a broad service account; storing groups while dropping direct users or links; flattening all products into one deny/grant rule; treating a direct Confluence restriction response as effective access; assuming every Drive child only gains access; ignoring SharePoint label encryption; accepting stale authorization indefinitely; and deleting a source while retaining derived personal data without a lawful reason.

Kevin Riedl

"The model is not your access control, and the prompt is not your security boundary. If a user is not allowed to read a document, the vector store must never return it. Everything else, the labels, the freshness, the audit log, is in service of that one rule."

Frequently Asked Questions

How do you enforce permissions in RAG?
Capture source-native authorization context on each chunk or keep an authoritative lookup, bind retrieval to the signed-in subject, and require a filter or live authorization decision before any result reaches the model. Include direct users, groups, links, inheritance, and protection controls where the source uses them.
Does RAG respect SharePoint permissions?
Not automatically. A custom RAG system must reproduce the relevant SharePoint and Graph decision, including direct and inherited permissions, links, site access, and sensitivity-label encryption, then security-trim before generation. Microsoft documents that Microsoft 365 Copilot respects the signed-in user's existing access.
What is security trimming in RAG?
Removing results the current user is not allowed to see. Early-binding security trimming applies the user's allowed-principal set as a mandatory filter at the search, so unauthorized documents are never returned, as opposed to post-filtering, which fetches then discards and is both slower and leak-prone.
How do you implement per-user permissions in RAG?
Bind each query to immutable user and tenant identifiers, resolve effective entitlements using the source's delegation model, and authorize before model context. Microsoft's on-behalf-of flow is one delegated-user option, not a universal pattern for Google or Atlassian.
Should I store user IDs or group IDs on each chunk?
Store every principal type that can affect access. Groups reduce cardinality, but direct user grants, domain or anyone links, inherited restrictions, and protected-content state can also be decisive.
How do I keep permissions fresh so I do not leak after a revocation?
Use source change feeds (Google Drive's Changes API, SharePoint delta plus indexer, Confluence polling) for incremental ACL sync, and explicitly resync inherited or parent-scope changes, the common blind spot. Either materialize faster with webhooks or do a live last-mile authorization check at query time.
Can I just tell the model not to reveal restricted documents?
No. OWASP lists prompt injection as LLM01, and NIST documents indirect injection through retrieved content. Enforce access in trusted retrieval or data-layer code before the model sees the content.
Can pgvector enforce per-user access?
PostgreSQL row-level security can enforce a predicate near pgvector data, but superusers, BYPASSRLS roles, and normally table owners bypass it. Use unprivileged application roles, FORCE ROW LEVEL SECURITY where appropriate, tested policies, and transaction-local request identity.
Are document embeddings personal data under GDPR?
They can be when they relate to an identifiable person, but not every embedding is categorically personal data. Assess content, linkability, inversion risk, purpose, retention, and erasure obligations for derived artifacts.
How does Confluence permission ingestion differ?
Effective viewing requires product and space access plus every applicable direct or inherited page restriction. A direct restriction response is not an effective-access decision; evaluate ancestors too, and separately govern public links because they can expose content outside normal restrictions.

Final thoughts

Enterprise RAG lives or dies on one rule: if a user cannot read a document, the model must never see it. Embeddings do not enforce source authorization, prompts are not a security boundary, and synchronized permissions create a real revocation window.

Preserve each source's effective-access semantics, authorize every result before generation, fail closed on stale state, and apply proportionate privacy controls to embeddings and logs. That is the foundation on which retrieval quality can safely matter.

Sources and further reading

  1. Microsoft 365 Copilot architecture, data protection, and auditing
  2. Microsoft: Restricted Content Discovery and Data Access Governance reports
  3. OWASP Top 10 for LLM Applications and NIST AI RMF Generative AI Profile
  4. Microsoft Graph: list DriveItem permissions and Selected permissions overview
  5. Atlassian: Confluence page restrictions, content restrictions API, and public-link security
  6. Google Drive API: manage sharing and Permissions resource
  7. Microsoft Entra ID token claims reference
  8. Microsoft identity platform OAuth 2.0 on-behalf-of flow
  9. PostgreSQL row security policies
  10. Google Drive API: change tracking overview
  11. Regulation (EU) 2016/679 (GDPR)
  12. Morris et al.: Text Embeddings Reveal (Almost) As Much As Text

Production AI help

Building an AI product and worried about inference cost, architecture, or production readiness? Wavect helps founders turn AI prototypes into reliable production systems.

Explore the service path:

Inbox, without the noise

Follow the work that matters to you

Get a short email when we publish something new. Follow the whole blog or only the problems you care about.

What would you like to receive?
Choose your topics

Free, double opt-in, no tracking pixels.

Back
Kevin Riedl

14 min read · 11 Jun 2026
Last reviewed

Next

Get the next AI and agents field note

One concise email when we publish. No tracking pixels, and no inbox filler.

Free, double opt-in, no tracking pixels.