How to Configure Firestore Replication User

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a firestore replication user by creating a service account with read permissions. Then you attach this role to your data sync pipeline. Most teams start by assigning a broad project role to get data moving fast. This quick fix gives the sync job power to change or delete live documents. If an attacker steals that key, they gain full control over your cloud database. A safer plan scopes the identity to read only the collections needed for transfer. How to set up a firestore replicati

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 replication user by creating a service account with read permissions. Then you attach this role to your data sync pipeline. Most teams start by assigning a broad project role to get data moving fast. This quick fix gives the sync job power to change or delete live documents. If an attacker steals that key, they gain full control over your cloud database. A safer plan scopes the identity to read only the collections needed for transfer.

How to set up a firestore replication user

Cloud databases do not use traditional database logins for server-to-server tasks. Instead, you create a dedicated cloud service account to act as the identity. This account represents your sync worker or change stream reader in the cloud project.

First, your team creates a new service account in the cloud identity console. You should name this account after the specific sync job it runs. Sharing one account across many pipelines makes it hard to track which job failed. Next, you attach a role that grants read access to your document collections. If the sync tool reads exports from cloud storage, the account needs storage read permissions. If the tool streams live document updates, it needs permissions to read database records.

After you assign the role, you link the identity to your worker nodes. When the sync worker runs inside the same cloud, it uses attached workload identity. This method avoids saving static secret files on disks. When the worker runs in an outside cloud, teams often generate a key file. You must rotate these external keys often so old secrets do not stay active.

Why a custom role reduces data sync risks

Prebuilt database roles often include both read and write rights in one package. A sync source job only needs to read records and watch for changes. It should never write data back to the source tables.

Building a custom role lets you strip away every write and delete permission. You pick only the exact read actions required by your sync engine. You can also add conditions that limit which resource paths the account can read. This setup stops a broken sync script from wiping out your primary records. It also limits what an attacker can do if they steal the worker credentials.

User Provisioning (SCIM) + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Where native cloud permissions fall short

Cloud roles do a great job of controlling which service account can log in. They also block a read-only sync worker from deleting a collection. Still, native roles stop checking once the identity passes the initial check.

Once a user or job has read rights, it can read every field inside a document. Native roles cannot hide sensitive fields inside a document while showing safe fields. If a document holds emails, phone numbers, or card numbers, the reader gets them all. Cloud access logs also focus on high-level API events rather than individual document reads. When an engineer uses the same service account to debug a sync error, problems grow. You cannot easily see which exact records the engineer read during that manual check. The cloud role decides who gets in, not what happens to fields in flight.

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

Does Firestore have a built-in database user for replication?

No, it relies on cloud service accounts instead of traditional database logins. You create a service account and assign read roles for your sync tool.

Should a replication account use static key files?

Avoid static keys whenever you can. Use workload identity federation so your sync worker authenticates without storing long-lived files on disk.

Can native cloud roles hide sensitive fields during a read?

No, native permissions work at the collection or document level. If an account can read a document, it reads every field inside that record.

The query runs. The emails stay hidden.