How to Configure Firestore Service Account
To set up a firestore service account, create an identity in your cloud project. Then, assign it a database role and link it to your app. Most teams start by creating one account for a backend app. They often pick a wide role so the app works right away. Still, wide roles let any user or script with that key change all data. If that key leaks, an attacker can read or delete every document. How a firestore service account works A firestore service account is a special identity for apps, not pe
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 a firestore service account, create an identity in your cloud project. Then, assign it a database role and link it to your app. Most teams start by creating one account for a backend app. They often pick a wide role so the app works right away. Still, wide roles let any user or script with that key change all data. If that key leaks, an attacker can read or delete every document.
How a firestore service account works
A firestore service account is a special identity for apps, not people. Your app uses this identity to log in and talk to the database. Cloud rules check the identity before they allow any read or write action.
First, an admin creates the account inside the cloud console. Next, the admin picks an identity role that fits the task. Some roles allow reading documents, while others allow writing or deleting them. You should pick the smallest role that lets your app do its job.
After you set the role, your app needs a way to log in. If your app runs on the same cloud, it can use built-in identity tools. The cloud platform handles the login step for your app behind the scenes. You do not need to save a secret file on a server.
Apps outside the cloud often use a downloaded key file or token exchange. A key file holds a private key that proves who the app is. Anyone who gets this file can act as that account from anywhere. Because of this risk, teams try to avoid long-lived key files when they can.
Why role checks are not enough for live data
Cloud roles do a good job of deciding who can log in. They block people and apps that do not belong in the project. They also split read roles from write roles at the project level.
Still, a role cannot see what happens inside an active session. Once an account logs in, it can read every collection in that database. You cannot use a cloud role to hide one sensitive document field. If a support engineer uses that account, every customer record comes back in full.
Service-to-Service Authentication + Service Account Governance: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Database security rules only apply to client apps on mobile or web. Backend apps that use a service account skip those client security rules. This means the account has full power up to its cloud role limit. One bad script or query can wipe out a whole collection in seconds.
Shared keys make audit logs very hard to read during an incident. When three engineers share one key file, the cloud log shows one identity. You cannot tell which person ran a delete command on Tuesday afternoon. You also cannot require a manager to approve a single risky write command.
Ways to reduce risk with database identities
Teams can take clear steps to keep database identities safe every day. Start by creating a separate account for each app or job you run. Never let two different apps share the same identity in production. If one app breaks or leaks a key, you can shut it down fast.
Next, stop engineers from downloading key files to their work laptops. Key files sit in downloads folders and get copied into chat messages. Rotate any existing keys on a set schedule and delete old unused keys. Check your cloud logs each week to find accounts that nobody uses anymore.
You should also separate human work from automated app work at all times. Give humans their own login path instead of sharing backend app keys. When people need to fix data, track each read and write action clearly. Adding data masking can rewrite emails, phone numbers, card numbers, and national IDs in results.
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 database security rules apply to a service account?
No, server libraries that log in with a service account skip client security rules. Instead, cloud identity roles control what that account can read or write.
How can I avoid downloading key files for my app?
Run your app on cloud compute services that attach the identity for you. For outside apps, use workload identity federation to trade short tokens instead of keys.
What happens if a service account key leaks?
Anyone with the key file can read or change your data from anywhere. You must delete the leaked key in the cloud console right away to stop them.
Related guides
In this post