AGENT SKILL
firebase-security-rules
Enforce access control in Firebase Security Rules, never in client code
- License 许可
- Apache-2.0
- 所属仓库
- linktogo/maggie
- 最近更新
- 2026-11-14
- Stars
- ★ 2
- Forks
- 2
01 前言 Front Matter
- name
- firebase-security-rules
- globs
- [ "firestore.rules", "storage.rules", "**/*.rules" ]
- description
- Enforce access control in Firebase Security Rules, never in client code
03 SKILL.md 正文
Firebase Security Rules
Security Rules are the authorization boundary. The client is untrusted — a check in your React/Next code is UX, not security.
Rules
- Default deny. Start from
allow read, write: if false;and open up only the specific paths and operations each role needs. - Authenticate then authorize: gate on
request.auth != nulland then on identity/ownership (request.auth.uid == resource.data.ownerId) or a role claim (request.auth.token.admin == true). - Validate writes in rules: check field types, required fields, and immutability
(
request.resource.data.ownerId == resource.data.ownerId) so a client can't escalate by editing a field. - Scope each rule tightly by operation. Split
writeintocreate,update,deletewhen they have different conditions. - Rules do not filter queries — they authorize document access. A
listquery must be constrained so every returned document satisfies the rule; otherwise it is rejected. Design queries and rules together. - Test rules with the emulator (
@firebase/rules-unit-testing) in CI: assert both the allowed and the denied cases.
Anti-patterns
- Relying on the app to "only request the user's own data" while rules allow any authenticated read.
- Putting secrets or admin logic behind rules that trust a client-set field.
- Custom claims changed but never refreshed on the client token (force a token refresh after a role change).
04 同仓库更多 Skills
vuejs-state-management
Manage Vue application state with Pinia and the right state locality
★ 2
vuejs-composition-api
Write Vue 3 components with the Composition API, script setup, and composables
★ 2
reactjs-hooks
Use React hooks correctly — dependencies, effects, and custom hooks
★ 2
reactjs-component-design
Write small, composable React components with clean props and no needless state
★ 2
postgres-query-performance
Diagnose and fix slow PostgreSQL queries with indexes and EXPLAIN
★ 2
postgres-migrations
Write safe, reversible, zero-downtime PostgreSQL schema migrations
★ 2