How to Configure Firestore IAM Authentication

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up firestore iam authentication, assign Google Cloud roles to your service accounts. Next, let your backend app log in with default cloud credentials. Many engineering teams start by giving broad project roles to developers and apps. This fast setup helps teams ship code, but it creates huge security risks. One overly broad role lets a user read or delete every document. How firestore iam authentication works in practice Google Cloud uses two distinct rule systems to guard your documen

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.

To set up firestore iam authentication, assign Google Cloud roles to your service accounts. Next, let your backend app log in with default cloud credentials. Many engineering teams start by giving broad project roles to developers and apps. This fast setup helps teams ship code, but it creates huge security risks. One overly broad role lets a user read or delete every document.

How firestore iam authentication works in practice

Google Cloud uses two distinct rule systems to guard your document database. Mobile and web apps use client security rules to check user logins. Backend servers and cloud workers use cloud identity roles instead. When you use firestore iam authentication, your app sends a signed token with each request. The cloud platform checks this token against your project role list.

To set this up, you first create a dedicated service account for your app. Next, you pick a database role that fits what the app needs. A viewer role lets the app read documents across the whole database. A user role lets the app both read and write data. An admin role lets a team member change database settings and manage indexes.

Human users follow a very similar path when they log in from local machines. Engineers log in through the cloud command tool to get temporary local tokens. Their local scripts then use those tokens to read or write production data. Teams should avoid using downloaded JSON keys because static files are easy to leak. Instead, workloads running inside the cloud should use attached service accounts to log in.

What native roles solve and where gaps remain

Native cloud roles do a great job of blocking strangers from your project. They make sure only known service accounts and team members can log in. They also help you split read rights from write rights at the project level. For automated backend apps with predictable tasks, this base layer works well.

Still, cloud roles are very broad once a user or script logs in. A standard database role applies to every collection and document in that database. You cannot use cloud roles alone to hide one specific collection from an engineer. If a developer has read rights for debugging, they can query every single record.

Service-to-Service Authentication + AWS IAM Policies: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

This creates a big gap when staff need to check live production data. Cloud roles decide who can log in, not what individual queries do in flight. They do not rewrite sensitive fields like emails, phone numbers, or card numbers in results. If a script runs a bad delete loop, the role will not stop it. Native audit logs also require extra setup and cost a lot at high scale.

Best practices for safer database role design

Start by removing broad project editor and owner roles from your daily users. Give each backend microservice its own unique service account with minimal read or write rights. Keep production databases in separate cloud projects from your staging and test data. This split stops a test script from wiping out live customer records by mistake.

For human engineers, avoid leaving permanent write roles active on production projects. Grant read roles only when someone needs to check a live bug. Review your project role list every month to remove old accounts and unused keys. Pair your cloud identity setup with runtime controls that inspect queries and mask sensitive fields.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev sits inline in the wire protocol beside those services as an open-source proxy, a sidecar for your Postgres or API. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run, and hoop.dev data masking rewrites matched sensitive values in responses in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

When should I use IAM roles instead of security rules?

Use IAM roles for trusted backend servers, cloud functions, and human engineers. Use security rules for untrusted mobile and web client apps that talk to the database.

Do IAM roles bypass database security rules?

Yes, requests that log in with cloud IAM roles bypass all client security rules. Because of this, you must keep backend service account permissions very tight.

How can I stop engineers from seeing private user fields?

Native IAM roles cannot hide specific document fields like emails or national IDs. You need a runtime layer that rewrites matched fields in query results before returning data.

The query runs. The emails stay hidden.