A newer version of the Gradio SDK is available: 6.14.0
Security Notes
This is a reference starter, not a production system. Use these notes to harden before deploying.
What is already safe-by-default
- Tenant isolation: the
tenant_idcolumn isolates data. The search query enforcestenant_id = X OR visibility = public. - Public vs restricted:
restricteditems never leak to other tenants unless explicitly requested. - Trust classes: retrieval can be gated by
max_rankso low-trust content is excluded. - Retrieval logging: every search is logged with filters and result IDs for audit.
- No private credentials: the repo contains no tokens, hostnames, or internal paths.
- Synthetic data only: all seed data is public-safe and fabricated.
What you must add for production
Authentication / authorization
- Add OAuth2, API keys, or mutual TLS.
- Bind
tenant_idto the authenticated user; never accept it from the request body. - Enable Postgres Row-Level Security (RLS) and tie policies to application-level user IDs.
Input validation
- Limit
contentsize (e.g. 100 KB) to prevent storage abuse. - Sanitize
metadataJSON to reject unexpected keys. - Rate-limit writes per tenant.
- Limit
Network security
- Do not expose Postgres port
5432to the internet. - Run the API and DB in a private VPC or behind a reverse proxy.
- Use TLS for all client↔API and API↔Postgres connections.
- Do not expose Postgres port
Secrets management
- Rotate
POSTGRES_PASSWORDimmediately; store it in a secrets manager (e.g. HashiCorp Vault, AWS Secrets Manager). - Never commit
.envfiles with real passwords.
- Rotate
Observability
- Alert on abnormal retrieval patterns (e.g. tenant A querying tenant B data).
- Monitor
retrieval_logsfor signs of probing or data exfiltration.
Backup and encryption
- Encrypt Postgres volumes at rest.
- Schedule automated backups and test restores.
Known limitations
- No authentication layer is included (by design, to keep the starter runnable).
- Placeholder embeddings are not semantically meaningful; swap in a real model before any serious use.
- HNSW index parameters (
m=16,ef_construction=64) are starter defaults; tune for your data size and recall requirements.