Firetool

Home / Docs / Roles and production safety

Docs

Firestore roles, read-only and production rules

How to set Firetool up for a team: mark projects and databases read-only or production, give people Viewer or Editor roles, protect collections, ask for reasons, lock the rules with a password, roll them out to every PC, and use the audit log.

How the rules work

Firetool's rules are called the policy. They are checked in the app's main process for every change: document edits, deletes, imports, copies, scripts, index changes and Authentication user changes. The window can't skip them. Every change, and every attempt the rules blocked, goes into the audit log.

The policy is kept on each computer, in ~/.firetool/policy.json, unless IT has put a machine policy in place (see Machine policy for IT). The rules protect against mistakes inside Firetool only. For protection in every tool, also give support staff Google accounts with read-only Firestore access, such as the Cloud Datastore Viewer IAM role, so Firestore itself refuses their changes.

Setting up the policy and reading the audit log work in the Free edition. Changing data needs Pro, so in the Free edition everyone is effectively a Viewer.

Mark a project or database read-only or production

  1. In the sidebar, right-click a project and choose Project settings…. For a single database (shown when a project has more than one), right-click the database and choose Settings….
  2. Under Whole project, tick Read-only or Production. Under Databases, tick them for one database only.
  3. Choose Save. If the policy has an admin password, type it first.

The sidebar then shows a lock for read-only (from 4.5.5; earlier versions show the word read-only) and a prod tag, and tabs show a Production badge.

  • Read-only: nobody can change data, indexes or users there from Firetool. Browsing, queries and exports still work. Read-only beats every role and the admin password unlock. A mark on the whole project covers all its databases.
  • Production: deletes, scripts, bulk changes (copies, transfers, imports, field changes, restores of several documents) and index changes ask you to type the project ID before they run. You type it once per operation, not once per batch. Editing a single document doesn't ask for the ID: from 4.5.1 it shows each field before and after and saves when you say so, with a copy you can restore. The question that asks for the project ID lists what the request changes: how many documents are created, updated, replaced or deleted, and the first few. From 4.5.5, a project's rules in Tools → Policy and roles can let changes to a few documents through without the question (Production: ask for the project ID when a change touches more than … documents or users, 1 by default); deletes, scripts and rules always ask.
The Confirm a production change dialog with a box to type the project ID and a Reason box

Authentication users belong to the whole project, so only the project's marks apply to them. In a production project, deleting users asks for the project ID.

Environment labels

In Project settings…, Environment labels a project as Dev, Staging, QA or Production. Each database can have its own label in the Environment column, or As the project.

  • The label shows on the project's tabs, next to the project in the sidebar, and in the header of an open collection, so you always know where you are.
  • It also colours the tabs (green, orange, violet or red), unless you've chosen a project colour.
  • Choosing Production also ticks the production rules above. You can untick them. From 4.5.5 the Production label also asks for a reason before every change, unless you untick it in Environment rules; Dev, Staging and QA change no rule on their own.

Read-only until unlocked

From 4.5.5, a label can keep its projects and databases read-only until someone unlocks them: tick Locked until unlocked for it in the Environment rules table of Tools, Policy and roles. Every change there is then refused until it's unlocked.

  • When a change meets the lock, Firetool asks to unlock it for 15 minutes to 4 hours, with a reason kept in the audit log, and then sends the change. The tab's Locked badge and Unlock for a while… in the command palette do the same before you start.
  • Lock again (the badge, or the command palette) locks it sooner. It locks again by itself when the time is up or Firetool restarts.
  • In the terminal, --confirm with the project ID unlocks that one command.
  • IT can set it in the machine policy: "unlockFirst": true for every project, or a list of projects and labels, such as ["prod", "shop-production"].

See Environment rules for the other rules a label can carry, including Always hide personal data.

Viewer and Editor roles

Open Tools, Policy and roles.

  • Default role, under Everyone on this computer: Editor: can change data (the default) or Viewer: read-only.
  • Roles for specific Google accounts: choose Add account, type the Google account or service account email and pick a role. That role applies in every project, whatever the project rules say.
  • A project can have its own role in its project rules, or Use the default role.

Firetool uses the first that applies: the account's own role, then the project's role, then the default role. If you list any accounts and Firetool can't tell which Google account a sign-in belongs to, that sign-in gets Viewer. A Viewer can browse, query and export, but can't change anything.

Project rules

In Tools, Policy and roles, choose Add project rules and type the project ID. Each project card has:

SettingWhat it does
Production, Read-onlyThe same marks as Project settings.
Ask for a reason for every change (saved in the audit log)Every change asks for a reason of at least 4 characters first.
Production: ask for the project ID when a change touches more than … documents or usersFrom 4.5.5: on a production project, changes to up to this many documents or users go through without typing the project ID (1 by default). Counted over the whole job, not per batch. Deletes, scripts and rules always ask.
Needs approvalDeletes, bulk changes and scripts wait for a colleague to approve a change request. See A second person's approval.
Allow exports (CSV/JSON)Untick to refuse exports from this project, including scheduled exports and user CSV exports.
Copying to another project counts as an exportWith exports off, also refuse copying collections, databases, differences, users or Storage files from this project into another project. Off by default, so copies work as before.
Also write audit entries to _studio_audit in this projectMirrors a summary of each entry into the project, so the team shares one log.
Read-only collections (comma separated, * wildcard)Nothing in these collections can be changed.
Collections nobody can delete fromDocuments in these collections can be edited but not deleted.
Most documents one delete may remove (0 = no limit)Counted over the whole operation, so it can't be passed in batches. Users count too.
Keep restorable copies ofSee Restorable copies.

Collection patterns: orders protects orders and everything inside it, including subcollections; cams_* matches every collection whose name starts with cams_; users/*/payments matches the payments subcollection of every user. Choose Save policy when you're done. Policy changes are recorded in the audit log.

A second person's approval

From 4.5.2, a project, or every project and database with an environment label, can need a colleague's approval before a risky change runs. Tick Needs approval in the project's rules or in the Environment rules table of Tools, Policy and roles. IT can list project IDs and labels in the machine policy instead: "requireApproval": ["prod", "shop-production"].

Change requests are kept in the team's shared file, so everyone involved needs Pro, the same shared file (team sharing, Settings, Team) and their own licence: who asked and who approved are the licences' email addresses.

  1. On a project that needs approval, a delete, a change to more than one document or user, an import, a restore or a migration doesn't run. Firetool shows Needs a second person's approval with what the first request would change: each document's fields now and after, with email addresses and phone numbers masked. Add a note and choose Send for approval. Nothing is changed.
  2. A colleague sees an Approvals pill, a line in Tasks and the request in Change requests (command palette). They read the note and the preview, add a note of their own if they like, and choose Approve or Decline. Nobody can approve their own request.
  3. You run the same action again. Firetool says who approved it and, when you choose Run it, the change goes through once, with the usual questions (the project ID on production, a reason if one is asked). The audit log's entries for it name the approver.
  • An approval covers exactly what was shown: the same documents, values and versions. If a document was edited since, or you change the action, Firetool offers a new request instead.
  • Each approval works once, and requests that aren't used within 7 days expire.
  • From 4.5.4, an approval isn't lost by a failed run: if Firestore accepts none of the change (a refusal, a dropped connection, a confirm you cancelled), the request goes back to approved and can run again. It counts as used once its first change is accepted. The audit log notes it.
  • A JS Query script can't write to such a project as it runs. Use Dry run: its Apply is what's sent for approval.
  • Single document edits aren't held: they show each field before and after on production and keep a restorable copy.
  • It's a guard for a team, not a lock: someone who edits the policy or the shared file on their own computer can get round it. For real enforcement, combine it with Google Cloud IAM roles.

Restorable copies

Keep restorable copies of decides which documents Firetool reads and saves in the audit log before changing them:

  • Automatic (the default from 4.5.1): on a project or database marked production, a copy of every document before each change, including imports, copies, restores, scripts and bulk changes; elsewhere, the same as the next choice. It costs one read per document changed on production. Policies saved by earlier versions read as Automatic.
  • Deleted documents, single edits and restores: copies of deleted documents, documents edited one at a time, removed fields, documents changed by Set, Rename or Delete field, and documents a restore or Undo writes over.
  • Everything that changes (more reads): also imports, copies and transfers that replace documents, restores and script updates. Each copy is one more Firestore read.
  • Nothing: no copies, so nothing can be restored from the log, and Undo can only remove documents a job created.

These copies are what Undo this operation uses to take a whole job back. Labels can carry rules of their own too: see Environment rules.

Lock the policy with an admin password

  1. In Tools, Policy and roles, type a password of at least 8 characters in Set an admin password (needed to change this policy later).
  2. Choose Save policy.

From then on, the policy and Project settings can only be changed after unlocking with the password. Unlocking also lets you make changes as an Editor for the rest of the session, except in read-only projects. Lock now locks it again, and Remove admin password takes the password off. Unlocks and wrong passwords are recorded in the audit log. Without a password, anyone using this computer account can change the policy.

Machine policy for IT

To apply the same rules on every PC, set them up on one computer, choose Save policy file for IT… in Tools, Policy and roles, and copy the file to:

SystemMachine policy file
WindowsC:\ProgramData\Firetool\policy.json
macOS/Library/Application Support/Firetool/policy.json
Linux/etc/firetool/policy.json

When this file exists, Firetool uses it instead of the user's own policy. It can't be changed or unlocked from inside the app; Policy and roles shows it read-only, and the Project settings switches are off. Make the file read-only for standard users. On Windows, for example:

icacls "C:\ProgramData\Firetool" /inheritance:r /grant:r Administrators:F /grant:r Users:RX

A machine policy can also hold "updateChecks": false, which turns off update checks and in-app updates, and two settings for team sharing: "sharedFile", the team's shared file for everyone (~ and %NAME% become each person's own folders), and "team": false, which turns team sharing off. "requireApproval" lists the projects and environment labels whose changes need a second person's approval. From 4.5.5, "unlockFirst" keeps projects read-only until unlocked, and "hidePersonalData" keeps logs, task bodies and Pub/Sub messages masked and functions' variable values hidden (Always hide personal data); each takes true for every project or a list of projects and labels. A small example:

{
  "defaultRole": "viewer",
  "users": { "lead@yourcompany.com": "editor" },
  "projects": {
    "shop-production": {
      "production": true,
      "requireReason": true,
      "readOnlyCollections": ["payments", "kyc_*"],
      "noDeleteCollections": ["orders"],
      "maxBulkDelete": 100,
      "allowExport": false,
      "snapshots": "all",
      "databases": { "analytics": { "readOnly": true } }
    },
    "shop-staging": { "role": "editor" }
  },
  "updateChecks": false
}

Roles are "viewer" or "editor". Write account emails in lower case and collection lists as JSON arrays. snapshots is "auto", "deletes", "all" or "none", matching the four choices of Keep restorable copies of. A policy left in the same place under the earlier name Firestore Studio still counts.

The audit log

Open Tools, Audit log. Each row shows the time, who (the computer user and the Google account), the project, the action, what changed, how many items, the reason and where it came from. Blocked attempts appear as Blocked by policy, and changes with saved copies show restorable.

  • Search: filter by Project ID (all projects) and by user, action, path or reason. Load older brings 200 more entries.
  • Verify integrity: each entry includes a SHA-256 hash of the one before it, so an edited or removed line breaks the chain. The check reads the whole log from the first entry and says either that all entries check out, or where the problem is.
  • Export CSV: saves the entries shown, with their hashes.
  • Open folder: the log is kept as one file per month, ~/.firetool/audit/audit-YYYY-MM.jsonl, one JSON line per entry.
  • A change missing from the log: from 4.5.4, if a change goes through but its line can't be written (another Firetool process kept the log locked for 30 seconds, or the disk is full), a banner under the tabs says so straight away: which change, in which project, and why. Such a change can't be undone or put back from the log. The banner stays until you close it, and Open audit log is one click.
The audit log in Firetool with time, who, project, action, what, count, reason and via columns, and restorable tags on edits and deletes

With Also write audit entries to _studio_audit on, each entry is also written as a document in the _studio_audit collection of the database where the change happened. That copy holds a summary (time, action, who, machine, up to 50 paths, count, reason and hash), not the saved document copies. Each one is one more Firestore write.

Restore from the audit log

  1. In Tools, Audit log, click an entry marked restorable.
  2. Choose Restore (it says how many documents), then confirm.

The documents are written back as they were before that change; any changes made to them since are replaced. Restoring is a change itself, so it needs Pro and follows the project's rules.

  • Only documents with a saved copy come back. Documents the change created aren't removed.
  • The account that made the change must still be added in Firetool.
  • Authentication users can't be restored, though deleted accounts' details are in the entry.
  • Very large single requests (over 1,000 documents) are logged without copies.

Questions

Is Firetool's read-only mode enough to protect production data?

It stops changes made in Firetool on that computer. Someone with write access in Google Cloud could still change data with another tool. For real enforcement, give support staff read-only IAM access, such as Cloud Datastore Viewer, and use Firetool's rules on top.

Does the production prompt appear for every document in a bulk job?

No. You type the project ID once when the operation starts, and the whole job, however many batches it sends, runs with it.

Can I see who changed a document last week?

Yes. In Tools, Audit log, type the document path or the collection name in the search box, and filter by project if you need to. Each entry shows who made the change, when, and the reason if one was asked for.