Prompt

How do I make an AI answer engine that respects permissions?

Artificial Intelligence / AI Search1 observationLast seen Nov 11, 2026

Latest observation

Nov 11, 2026OpenAI APIWeb search: off

To build an AI answer engine that respects permissions, treat permissions as a first-class security layer around the model—not something the model “just knows.”

Core principle

Never let the model decide access by itself.
Your application should:

  1. authenticate the user,
  2. determine what they’re allowed to access,
  3. retrieve only permitted content,
  4. give the model only that content,
  5. enforce output filtering before returning the answer.

Recommended architecture

1) Authenticate the user

Use your normal auth system:

  • SSO/OAuth/SAML
  • session cookies
  • API keys
  • service accounts

Identify:

  • user ID
  • roles/groups
  • org/team
  • tenant
  • clearance level

2) Authorize at retrieval time

When the user asks a question, translate that into a search/query over your knowledge base or documents, but apply ACL checks before retrieval.

Examples of permission rules:

  • user can only see docs in their team
  • user can see docs with tags matching their clearance
  • user can see documents they own
  • some fields in a document are masked unless privileged

Best practice:

  • store ACL metadata on every document/chunk
  • filter results using the user’s permission context
  • do not retrieve unauthorized text at all

3) Use permission-aware indexing

For RAG systems, build your index with metadata such as:

  • tenant_id
  • document_id
  • allowed_roles
  • allowed_users
  • department
  • sensitivity
  • classification

Then during search:

  • filter by metadata before or during vector search
  • or do a two-stage retrieval:
    1. broad candidate search
    2. authorization filter
    3. rerank only permitted candidates

4) Pass only permitted context to the model

The LLM should only see:

  • the user question
  • approved context snippets
  • minimal metadata needed for citation

Do not pass:

  • hidden docs
  • raw ACL tables
  • unauthorized chunks “just in case”

5) Enforce output filtering

Even with correct retrieval, the model may infer sensitive details from context. Add a final policy check before sending the response.

Examples:

  • redact secrets, PII, internal IDs
  • block answers if they reveal unauthorized info
  • replace with “You don’t have access to that information”

6) Prefer “deny by default”

If permission is unclear:

  • do not answer from hidden sources
  • ask the user to request access
  • or provide a safe, generic answer

Practical patterns

Pattern A: Document-level ACL

Simplest:

  • each document has an access list
  • user can retrieve only if they’re on the list

Good for:

  • enterprise knowledge bases
  • policies
  • wikis

Pattern B: Row/field-level security

Needed when one document contains mixed sensitivity:

  • retrieve doc
  • mask restricted fields before prompting
  • use structured extraction to separate public vs sensitive parts

Pattern C: Tenant isolation

For multi-tenant systems:

  • every query must include tenant_id
  • index partitioning or strict filters
  • never allow cross-tenant retrieval

Pattern D: Policy engine

Use a centralized policy engine like:

  • OPA/Open Policy Agent
  • Cedar
  • Zanzibar-style authorization

This gives consistent decisions for:

  • search
  • retrieval
  • tool use
  • response delivery

Important security mistakes to avoid

  • letting the LLM read all documents and “be careful”
  • relying on prompt instructions for access control
  • retrieving first and filtering later only in the UI
  • using embeddings without ACL metadata
  • caching responses without permission scoping
  • allowing tool calls that bypass authorization
  • leaking through citations, summaries, or examples

Minimal implementation flow

  1. User asks a question
  2. Backend authenticates user
  3. Backend computes permissions
  4. Retrieval layer searches only authorized sources
  5. LLM generates answer from permitted context
  6. Output filter checks for sensitive leakage
  7. Return answer or deny

Simple pseudocode

def answer_question(user, question):
    perms = get_permissions(user)

    candidates = search_index(question, filters={
        "tenant_id": user.tenant_id,
        "allowed_roles": perms.roles,
    })

    authorized = [doc for doc in candidates if can_access(user, doc)]

    context = build_context(authorized)

    response = llm.generate(
        system_prompt=POLICY_PROMPT,
        user_prompt=question,
        context=context,
    )

    if violates_policy(response, user):
        return "Sorry, I can’t provide that information."

    return response

If you want strong guarantees

Use all of these:

  • authenticated users
  • permission-aware retrieval
  • structured ACLs
  • policy engine
  • output redaction
  • auditing/logging
  • tests for unauthorized leakage

Good test cases

Verify the system fails safely for:

  • user without access to a doc
  • user with partial access to a doc
  • cross-tenant query
  • prompt injection trying to reveal hidden docs
  • model hallucinating unauthorized info
  • cached response shown to wrong user

If you want, I can also give you:

  1. a reference architecture diagram,
  2. a Python/FastAPI example, or
  3. a vector database ACL design for permission-aware RAG.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.