Skip to content
Projects

Lantern

Permission-aware multi-tenant RAG with authorization enforced inside the vector query

Open source Source

Answers questions over shared documents (visible to every organization) and tenant documents (visible only to the uploading organization). Every query follows one fixed order: verified identity, authorization filter, filtered vector search, context, LLM. The filter is built in one place from the signed token and never from request input, so authorization does not depend on the model. PDFs with tables and figures are parsed with Docling; prose, Markdown tables and vision-model image captions are indexed separately, the last two with their own embedding model. Operations are covered too: an append-only audit log that fails closed, login lockout with emailed reset, token revocation, per-tenant rate limits, JSON logs, Prometheus metrics, and a chat UI that shows the retrieval trace of every answer. A self-built project on a small demo corpus with seeded demo tenants, not a deployed multi-customer service.

What it does

  • Tenant, scope and role filters are bound SQL parameters inside the vector query, built from the verified JWT and never from request input
  • Adversarial isolation evaluation scored against an independent oracle, plus a test proving it fails when isolation is removed
  • Docling ingestion of PDFs: prose, Markdown tables and vision-model image captions indexed separately with their own embedding model
  • Relative relevance cutoff raised relevant context from 35% to 78% with no recall loss on the benchmark
  • Append-only audit log that fails closed (a failed audit write fails the request); a database trigger rejects UPDATE and DELETE
  • Login lockout with emailed reset, token revocation, per-tenant rate limits, JSON logs with request ids, Prometheus metrics
  • Retrieved text is escaped, delimited and declared untrusted; the LLM is skipped when nothing is retrievable
  • Chat UI with a retrieval trace for every answer: which passages, tables and figures were used, with scores

Pipeline

  1. 1JWT → verified identity (tenant, roles)
  2. 2Authorization filter (one module)
  3. 3Filtered pgvector search (prose + tables/images)
  4. 4Context builder (escaped, marked untrusted)
  5. 5Ollama generation with citations
  6. 6Append-only audit log

Results

Adversarial isolation suite138 attack queries, 5 users, 552 chunks retrieved: 0 unauthorized, 0 cross-tenant, 0 canary leaks; scored against an independent oracle0 leaks
Authorized access preservedauthorized probes still found; a test proves the suite fails when isolation is removed22 / 22
Retrieval benchmark (19 queries, small demo corpus)a benchmark, not production accuracyRecall@1 0.947, MRR 0.974
Relevant context after relative cutoffno recall loss on the 19-query benchmark35% → 78%