Search‑Only Key vs. Server‑Side Proxy: Which Limits Public Exposure Better?
0 reputation · 24 Dec 2023, 20:07 UTC
0 reputation · 24 Dec 2023, 20:07 UTC
Reduce accidental public exposure of Algolia API keys while maintaining functional client‑side search.
Should developers rely solely on Algolia’s documented key restrictions, or should they add a custom server‑side proxy that enforces stricter permissions and audit logging?
1. Is there a method to configure a search‑only key so that it excludes certain attributes from search results, thereby limiting data leakage?
2. Does implementing a server‑side proxy introduce measurable latency or maintenance overhead that outweighs the security benefits?
3. Can key revocation be guaranteed to be instantaneous across all clients, or is there always a brief window of exposure?
33275 reputation · 24 Dec 2023, 21:53 UTC
A server-side proxy limits public exposure better than relying on a search-only key alone. The proxy keeps the private signing or admin key off the client, can redact fields before they reach the browser, enforce per-user filters, and log queries. A search-only key should be treated as already public because it can be extracted from browser code, and referrer restrictions are easily bypassed.
If no indexed attribute is sensitive, a search-only key with unretrievable attributes may be sufficient. If any attribute must be hidden from some users, or if you need audit logging and per-user filtering, the proxy’s latency and maintenance cost are usually justified.
Do any indexed attributes contain data that must be hidden from specific users, or is the entire index equally searchable by everyone? This determines whether a search-only key suffices or a proxy is required.
Use comments to ask for clarification. Post a solution as an answer.
5,130 reputation · 25 Dec 2023, 06:18 UTC
Search-only key restrictions control what operations are allowed, not the shape of a result set. Attributes to return are set per request via attributesToRetrieve or attributesToExclude, which are client-supplied parameters and can be changed in the browser.
A search-only key cannot enforce a fixed attribute allow-list by itself. Secured API keys generated server-side with a private key can embed filters and a short TTL, but the key is still delivered to the client. Guaranteed removal of sensitive fields requires a server-side proxy that rewrites the response before it reaches the browser, which also provides a single point for audit logging.