How to Configure Firestore Read Only User

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a firestore read only user by assigning a viewer role in cloud identity. You can also write database security rules that allow read calls and block write calls. Most teams start by giving developers broad project roles during early builds. Those broad roles let anyone change or delete live documents by mistake. A single bad script can wipe out customer records in seconds. Moving to read-only roles protects your production data from human error. How to set up a firestore read only us

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You set up a firestore read only user by assigning a viewer role in cloud identity. You can also write database security rules that allow read calls and block write calls. Most teams start by giving developers broad project roles during early builds. Those broad roles let anyone change or delete live documents by mistake. A single bad script can wipe out customer records in seconds. Moving to read-only roles protects your production data from human error.

How to set up a firestore read only user

Cloud platforms offer two main ways to control who reads your document store. The first path uses cloud identity roles for team members and backend services. The second path uses database security rules for client apps and web users. Both methods stop write requests before they change your stored data.

To set up a human user or service account, use your cloud identity console. Pick the team member or service identity that needs to view data. Assign the built-in viewer role made for your document database. This role grants permission to list collections and read documents across the project. It blocks all create, update, and delete actions at the cloud API level.

If you use client SDKs, cloud identity roles are not the only check. Client requests often run through the database security rules engine instead. In your rules file, you define match blocks for your document paths. You set the read condition to true for verified users with viewer claims. You set the write condition to false so no client can alter records.

What native read-only roles solve and what they miss

Native viewer roles do a great job of stopping accidental data changes. Developers can inspect document structures and debug issues without risking live state. Support teams can look up order records without fear of deleting a profile. Auditors can verify system state while knowing their account cannot change anything.

Still, native cloud roles have a major blind spot for security teams. A project viewer role applies to every collection and document in that database. It cannot hide specific fields inside a document from a human reader. When a user fetches a document, the database returns the whole object.

This all-or-nothing read model creates a privacy risk for sensitive customer data. A developer checking a bug might pull a document with private details. That record could hold emails, phone numbers, card numbers, or national IDs. Native roles decide who can log in and read a collection. They do not inspect or filter the actual fields returned in flight.

Read-Only Root Filesystem + User Provisioning (SCIM): architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Managing service keys and audit logs for viewers

Many teams also create read-only service accounts for reporting scripts and local tools. Engineers often download key files to run queries from their own laptops. Once a key file leaves the cloud console, you lose track of it. Anyone who finds that key file on a disk can read your database.

Cloud audit logs also require extra setup to track data read events. By default, platforms log admin changes rather than every single document read. Turning on full data read logs for a busy app creates huge log bills. Even with logs turned on, you only see that a role read a document. You still cannot mask sensitive fields like card numbers before the user sees them.

To reduce risk, teams should avoid static key files on developer machines. Use short-lived sessions tied to a single person and their work email. Pair those sessions with field-level masking that rewrites matched fields in results.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev sits inline in the protocol beside each supported service as an open-source proxy, a sidecar for your database or API. For every query or command an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human approval.

First, hoop.dev guardrails block banned queries before they run or hold risky ones for review, and hoop.dev data masking rewrites matched sensitive values in responses in memory. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

Can a firestore read only user still run queries and list collections?

Yes, a viewer role allows the user to list collections and run read queries. They can filter, sort, and fetch documents, but they cannot write or delete data.

Do database security rules override cloud identity viewer roles?

No, they work on different request paths. Server SDKs and the cloud console check cloud identity roles, while mobile and web client SDKs check security rules.

Can native roles hide a single field like an email inside a document?

No, document reads return the full record. Native roles and rules work at the document level. As a result, they cannot strip out individual fields like emails or phone numbers.

The query runs. The emails stay hidden.