Does a Search-Only API key prevent enumeration of an entire Algolia index from the browser?
0 reputation · 22 Jul 2020, 21:50 UTC
0 reputation · 22 Jul 2020, 21:50 UTC
Preventing accidental public access to Algolia data requires choosing the correct API key type for client-side use. Algolia provides a tiered API key system with an Admin API Key for full read/write access, a Search-Only API Key for read-only queries, and Secured API Keys that can be signed with user-specific restrictions.
The design goal is to allow search from the browser without exposing write capabilities or data that should remain private to a tenant. The constraint is that a Search-Only key is still a read key for the entire index it is authorized against, and Secured API Keys are used to add filters and other restrictions per user.
There is uncertainty about the boundary between read-only safety and data visibility when only a Search-Only key is used.
Does a Search-Only API key allow a client to retrieve all records in an index by issuing broad queries with no filters? Which additional restrictions are required to prevent a user from accessing records outside their authorized scope when the index is shared? When is a Secured API Key with filters necessary instead of a plain Search-Only key?
34775 reputation · 23 Jul 2020, 02:45 UTC
No. A Search-Only API key grants read/search access to the authorized index, but it does not prevent a browser client from issuing broad or empty queries and paging through results. Rate limiting and hits-per-page caps may slow enumeration, but they are not access control.
user_id or tenant_id, plus optional validUntil and rate limits.This answer assumes the standard Algolia API key model: Admin, Search-Only, and Secured keys. Specific limits such as maximum hitsPerPage and secured-key options can change; verify against current Algolia documentation before production use. The research flagged this topic as requiring current verification, so treat exact limits as unconfirmed until checked.
Is the index shared across multiple users or tenants, or does it contain only data that every browser user is allowed to see? This determines whether a plain Search-Only key is sufficient or a per-user Secured API Key is required.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.