mmday-firebase/firestore.rules
윤정민 b67125f412 Add AI chat persona and infrastructure for the "Jjaek" chatbot.
- AI 챗봇 '짹'의 페르소나 정의 및 시스템 프롬프트 상수를 추가했습니다.
- 채팅 이력, 쿼터 관리, 요청 멱등성 보장을 위한 Firestore 데이터 모델을 구현했습니다.
- 위기 상황 대응(자해·위해 예고 등) 및 입력/출력 필터링 파이프라인을 구축했습니다.
- Gemini 및 Anthropic 모델을 지원하는 AI Provider 추상화 계층을 마련했습니다.
2026-06-15 13:07:58 +09:00

75 lines
2.1 KiB
Plaintext

rules_version='2'
service cloud.firestore {
match /databases/{database}/documents {
match /users/{uid} {
allow read: if request.auth != null && request.auth.uid == uid;
allow update: if request.auth != null && request.auth.uid == uid &&
request.resource.data.diff(resource.data)
.affectedKeys().hasOnly(['fcmToken']);
allow create, delete: if false;
match /voteHistory/{date} {
allow read: if request.auth != null && request.auth.uid == uid;
allow write: if false;
}
match /attendance/{month} {
allow read: if request.auth != null && request.auth.uid == uid;
allow write: if false;
}
match /pointLedger/{id} {
allow read: if request.auth != null && request.auth.uid == uid;
allow write: if false;
}
// AI 채팅(짹) — 전부 Admin SDK(서버) 전용. 클라이언트가 직접 읽으면
// 프롬프트 노출, 직접 쓰면 한도 우회·이력 위조(영속 인젝션)가 가능해진다.
// 이력 조회도 GET /chat/messages 경유. (ai-chat-tech-design.md §4.6)
match /chatThreads/{threadId} {
match /{document=**} {
allow read, write: if false;
}
allow read, write: if false;
}
match /chatQuota/{date} {
allow read, write: if false;
}
match /chatRequests/{clientMessageId} {
allow read, write: if false;
}
}
// 시스템 프롬프트·필터 사전·한도 설정 평문 보관 — 노출 시 §7.5 무력화
match /config/{doc} {
allow read, write: if false;
}
// 신고 적재함 — Admin(운영) 전용. 생성도 서버(POST /chat/.../report) 경유
match /chatReports/{reportId} {
allow read, write: if false;
}
match /games/{gameId} {
allow read: if true;
allow write: if false;
}
match /kboCache/{key} {
allow read: if true;
allow write: if false;
}
match /kboLocks/{key} {
allow read, write: if false;
}
match /{document=**} {
allow read, write: if false;
}
}
}