Skip to content

security: version Firestore rules/indexes; dev and CI on emulators (PR 1.3) - #11

Merged
Jeston10 merged 2 commits into
milestone/p1-securityfrom
security/firestore-rules-indexes
Sep 20, 2026
Merged

Jeston10 merged 2 commits into
milestone/p1-securityfrom
security/firestore-rules-indexes

Conversation

@Jeston10

Copy link
Copy Markdown
Owner

Summary

PR 1.3 of docs/MILESTONES.md (Phase 1). SECURITY §2.7 — Firestore locked to admin-only access, indexes versioned, and the emulators wired into dev and CI.

  • firebase/firestore.rules — deny-all for the client SDK; tests/integration/firestore-rules.test.ts (rules-unit-testing) asserts anonymous and owner reads/writes are denied
  • firebase/firestore.indexes.json — the three composite indexes mirrored from production via the Firestore Admin API (read-only); every query probed against production
  • Emulator mode: service account optional when emulator hosts are set (cross-field check in config/env.ts, server-only); cert-less Admin init; browser Auth SDK → emulator
  • scripts/seed-emulator.ts (refuses non-emulator targets) + pnpm dev:emulators / pnpm emulators / pnpm seed:emulators; firebase/README.md
  • CI: integration job runs the rules test; e2e job runs the app in emulator mode with seeded data (no more SKIP_ENV_VALIDATION at runtime); firebase-tools pinned; pnpm test = unit project only

Type

  • security - [x] test - [x] ci

Verification

  • pnpm lint ✔ · typecheck ✔ · knip ✔ · vitest 24/24 unit ✔
  • next build: normal mode ✔ · emulator mode with no service account ✔ · neither configured → fails with the named error ✔
  • Production probe (read-only): all 4 queries succeed; indexes listed and mirrored
  • Rules integration test + seeded e2e: CI (local JDK is 19; emulator needs 21)

Server checklist

  • Client SDK cannot read or write (rules + test)
  • Every query has a committed index (firebase/README.md table)
  • Scripts/tests may read process.env (tooling override, documented); app code still cannot

Risk watch-list

  • Rows checked: R17 — closed: query is valid in production and indexed; index committed
  • R5 standing: no Firebase Storage (only Auth + Firestore emulators configured)

Docs

  • firebase/README.md, CONTRIBUTING.md (emulator workflow), .env.example, docs/RISKS.md

🤖 Generated with Claude Code

PR 1.3 of docs/MILESTONES.md (SECURITY §2.7).

- firebase/firestore.rules: deny-all for the client SDK (data access is
  admin-only). Integration test with @firebase/rules-unit-testing
  asserts anonymous and owner reads/writes are denied.
- firebase/firestore.indexes.json: the three composite indexes mirrored
  from the production project via the Firestore Admin API; every app
  query probed read-only against production (RISKS R17 closed: the
  `userId !=` + orderBy query is valid and indexed).
- Emulator mode: FIRESTORE_EMULATOR_HOST / FIREBASE_AUTH_EMULATOR_HOST
  make the service account optional (cross-field check in config/env.ts,
  server-only); firebase-admin initialises without credentials; the
  browser Auth SDK connects to the emulator via
  NEXT_PUBLIC_FIREBASE_AUTH_EMULATOR_HOST.
- scripts/seed-emulator.ts (refuses to run against a real project) and
  `pnpm dev:emulators` / `pnpm emulators` / `pnpm seed:emulators`.
- CI: integration job runs the rules test inside emulators:exec; e2e
  job now runs the app in emulator mode with seeded data instead of
  skipping env validation at runtime. firebase-tools pinned as a
  devDependency. `pnpm test` runs the unit project only.

Verified: pnpm lint, typecheck, knip, vitest 24/24 (unit), next build
in normal mode, in emulator mode without a service account, and the
named error when neither is configured. Rules test runs in CI (local
JDK is 19; emulator needs 21).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 16, 2026 04:43
@vercel

vercel Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
just-prep-ai-interview-z3cv Error Error Sep 16, 2026 4:51am UTC

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Jeston10
Jeston10 merged commit 4b22164 into milestone/p1-security Sep 20, 2026
6 of 7 checks passed
@Jeston10
Jeston10 deleted the security/firestore-rules-indexes branch September 20, 2026 09:50

This branch had an error being deployed

1 failed deployment
Preview — b2ba8c08 Deployed Sep 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants