Skip to content
Skip to this exploration
All explorations

Practical self-hosting · intermediate

26 · One engine, separate memories

Treat retrieval authorization as a server responsibility.

10 min 5 sectionsv1

What you can take away

  • Design cross-user denial tests with synthetic records.
  • Write denial tests for search, direct document fetch, citation preview, export, and cache reuse

Your trail through this idea

Checking saved progress…

A search finds a perfectly relevant passage from somebody else’s private notes. Retrieval quality is high; the service has still failed. Shared infrastructure does not imply shared permission.

Prerequisite: complete the preceding lesson or bring its worksheet.

Mark sections complete when you choose. Reading alone does not mark them.

Understand the system

Authorization must constrain the records available to a request before their content reaches the model or client. A user-supplied filter is not enough if the user can remove or alter it. Qdrant’s security page is further reading; it resolved but its text was unavailable during this review. The application must enforce its own identity-to-data policy. Database access and end-user access are different layers.

Cache keys, conversation memory, exports, citations, and logs can cross the same boundary. Testing only the search endpoint leaves other routes unexamined. A model instruction to 'keep secrets' cannot compensate for sending another user’s data into its context.

Checking saved progress…

Work through the case

Original fixture: fictional account A owns document ALPHA; fictional account B owns document BETA. Both contain the word 'garden', but different synthetic facts. A search by A must never return BETA, including through a cached result or guessed document identifier. The data is invented specifically so the test reveals leakage without exposing anyone.

Checking saved progress…

Make something useful

Try this

Original exercise

Write denial tests for search, direct document fetch, citation preview, export, and cache reuse. Include a missing identity and a forged owner parameter. Expected result: server denial or no unauthorized content, not an apologetic model answer after disclosure. Run only against a disposable staging collection and remove the test accounts afterward.

Runnable authorization-boundary lab

This original Python 3 toy uses fictional principals and documents. Save it as lesson_access.py and run python3 lesson_access.py. It models a server-side policy decision; it does not implement authentication or prove a production Qdrant deployment is secure.

docs = {
    "ALPHA": {"owner": "A", "text": "The fictional garden has blue stones."},
    "BETA": {"owner": "B", "text": "The fictional garden has red stones."},
}
def fetch(authenticated_principal, document_id):
    record = docs.get(document_id)
    if (authenticated_principal is None or record is None
            or record["owner"] != authenticated_principal):
        raise PermissionError("not available")
    return record["text"]

assert fetch("A", "ALPHA").endswith("blue stones.")
for principal, document_id in [("A", "BETA"), ("B", "ALPHA"),
                                (None, "ALPHA"), ("A", "UNKNOWN")]:
    try:
        fetch(principal, document_id)
    except PermissionError:
        pass
    else:
        raise AssertionError("unauthorized disclosure")
print("PASS: one allowed read and four denied reads")

Expect the PASS line. Remove the owner comparison and rerun; the test should fail on cross-user access. Restore it. In a real service the principal must come from verified server authentication, never from a caller-controlled owner parameter. Repeat equivalent tests for search, export, citation previews and caches; this toy covers only direct fetch. It writes no files beyond the script you save. Delete that script to clean up.

Checking saved progress…

Check your reasoning

A quick check · for your own learning

Where should cross-user retrieval restrictions be enforced?

Choose one answer

A self-study prompt. You can retry; this is not an exam.

Checking saved progress…

Keep the result and follow the sources

Success is evidence that every content route respects the same boundary. Keep private chat provenance and family research outside public lesson bundles even when the lesson status is draft.

Sources and scope

  • Primary documentation or archival source, link resolved 14 November 2026; page text could not be inspected. Additional direct links appear beside the claims they support.
  • Editorial basis: Ian's historical self-hosting questions and current repository inspection informed the case selection. Historical requests do not establish current deployment. Private chat records, credentials and host details are excluded.
  • Examples and exercises are original educational synthesis. External sources support the stated technical or historical context, not every hypothetical scenario.
Checking saved progress…

These checks are for reflection and practice. Your answers and reflection notes are not sent anywhere.

Back to all explorations