Edit and publish security rules
Change the Firestore rules of a database, on Google or on an emulator.
- Step 1: Expand a database in the sidebar and choose Rules, or use the Security rules button in a collection toolbar. A Rules tab opens with the project and database selected.
- Step 2: Edit the rules in the editor. The label Unsaved changes appears when the text differs from what is published.
- Step 3: Choose Publish. The app asks Publish Firestore security rules? and names the database and project.
- Step 4: Confirm. The new ruleset replaces the published rules for every client.
- Reload replaces the editor text with the published rules. If you have unsaved changes it asks first.
- If the database has no published rules yet, the app shows a default template and says No published rules yet.
- If the rules have errors, publishing is refused and the app lists them with line and column.
- Cmd/Ctrl+S asks to publish with the same confirmation. It never publishes directly.
- When the button reads Up to date, the editor matches the published rules.
Warning: Switching database or project with unpublished changes opens Unsaved security rules with Keep editing, Publish & switch and Discard. Publishing changes who can read and write your data. The app has no rules test tool or version history, so test rules in an emulator first.
On an emulator connection the Rules tab shows the rules the emulator enforces. There is no project selector and no console link.
- Validate compiles the rules in the editor without applying them. Errors show with line and column, and a clean result says The rules compile.
- Apply to emulator replaces the rules the running emulator enforces for that database. It changes only the emulator memory: the rules file on disk is not changed, and the rules are lost when the emulator restarts.
- For Storage, the emulator cannot report its rules. The app shows a template, and applying replaces the rules for the whole Storage emulator, every bucket.