How to Configure Firestore Grant Permissions

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up firestore grant permissions by assigning cloud roles or writing security rules. Cloud roles control backend admins, while security rules check mobile and web app requests. Most engineering teams start by giving developers broad project roles to move fast. Broad roles let anyone read, change, or delete whole collections in your live database. A single bad query or script can wipe out customer records in seconds. How firestore grant permissions work in practice Google Cloud splits da

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 firestore grant permissions by assigning cloud roles or writing security rules. Cloud roles control backend admins, while security rules check mobile and web app requests. Most engineering teams start by giving developers broad project roles to move fast. Broad roles let anyone read, change, or delete whole collections in your live database. A single bad query or script can wipe out customer records in seconds.

How firestore grant permissions work in practice

Google Cloud splits database control into two distinct layers for different types of users. The first layer uses cloud identity roles for engineers, servers, and backend scripts. You attach a role to a user account or a backend service account. That role allows reading data, writing documents, or managing indexes across the whole project. Cloud roles apply to every collection and document inside that specific database instance.

The second layer uses declarative security rules for web and mobile client apps. Client requests carry an identity token from the login service to the database. The database checks the security rule file before it reads or writes any document. Rules can check if the user ID matches a field inside the target document. If the rule check passes, the database runs the read or write operation right away. Server SDKs and admin tools bypass these client security rules when using cloud roles.

What native roles solve and what they miss

Native roles and security rules solve the initial problem of who can log in. They block unknown users and keep client apps from reading another customer's documents. Service accounts also let backend apps log in without sharing personal developer passwords.

Still, native cloud roles leave a large gap for human engineers and admin scripts. Cloud roles work at the project or database level, not the document level. An engineer with a viewer role can pull every email, phone number, and card number. An engineer with an editor role can overwrite live production records without a peer check. Native roles decide who can connect, not what individual queries do in flight. They do not rewrite sensitive fields in results or pause risky writes for approval.

AI Agent Permissions + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

How to tighten database roles for your team

Start by removing broad project editor and owner roles from daily developer accounts. Give engineers read-only roles on staging databases and zero standing roles on production. Use separate service accounts for each backend app so you can track every query source. Turn on cloud audit logs to record who ran admin actions against the database.

When someone needs to fix data in production, check every command before it runs. Masking rules can rewrite emails, phone numbers, and national IDs in query results. This approach keeps daily debugging fast while protecting sensitive customer records from accidental exposure.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits inline in the protocol beside the service as an open-source proxy, a sidecar for your database or API. On every production query an agent or human runs, hoop.dev decides whether to pass, mask, block, or escalate it for review.

Before a query runs, hoop.dev guardrails check the statement against your rules, an AI Analyzer you configure can score intent or hold risky calls for human approval, and hoop.dev data masking rewrites sensitive fields in responses in memory. Explore the MIT-licensed project on GitHub.

Frequently asked questions

Do cloud identity roles override client security rules in Firestore?

Yes, requests that use cloud identity roles bypass client security rules completely. Admin SDKs and developers with cloud roles can read or write any collection allowed by their role.

Can I grant a cloud role to a single Firestore collection?

No, cloud identity roles apply to the whole project or database instance. You cannot scope a native cloud role to one single collection or document.

How do I protect PII when developers query Firestore?

Native cloud roles return full documents to anyone with read permissions. To hide sensitive fields, you must apply data masking that rewrites emails or card numbers in results.

The query runs. The emails stay hidden.