Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Firestoreのルール設定 割と何でも出来てビビる/Firestore rule s...
Search
kkznch
May 17, 2019
Technology
1
700
Firestoreのルール設定 割と何でも出来てビビる/Firestore rule setting
Webナイト宮崎 Vol.4
登壇枠で使用
参考URL
https://tegehoge.connpass.com/event/128502/
kkznch
May 17, 2019
Tweet
Share
More Decks by kkznch
See All by kkznch
黒い画面へようこそ/Hello, black screen
kkznch
0
350
VueRouterとNuxtのルーティング/VueRouter and Nuxt Routing
kkznch
0
310
Vuexで何を管理する方が良い?/What is better to store in Vuex?
kkznch
1
680
LaraCSVで手軽にCSVを出力する/Easily generate CSV by LaraCSV
kkznch
0
1.6k
自社サービス チャット機能にFirebaseが導入されてた/Firebase was introduced to the chat function of our service
kkznch
0
1.1k
SPA開発未経験者によるNuxt.jsを使った自社サービス開発 / Development of own service using Nuxt.js by inexperienced SPA development
kkznch
3
3.1k
Laravel Telescopeが便利そうな気がする/Laravel Telescope seems to be convenience
kkznch
1
1k
Laravel Novaはなんだかいい感じらしい/Laravel Nova seems to be nice
kkznch
0
590
Laravel5.5的 継続的インテグレーション / Laravel 5.5 Continuous Integration
kkznch
3
3.3k
Other Decks in Technology
See All in Technology
AI時代のアジャイル開発(XP祭り2024版) / Agile Development in the AI Era in XPJUG
takaking22
13
3.4k
不感対策ソリューション
jtes
0
230
LINEヤフー新卒採用 コーディングテスト解説 実装問題編
lycorp_recruit_jp
1
12k
【shownet.conf_】ShowNet 2024 ~ Inter * Network ~
shownet
PRO
0
370
クロージング / MIERUNE JCT - Tokyo 2024
mierune
PRO
0
290
AWSへのNIST SP800-171管理策 導入に向けての整備/20240930 Mitsutoshi Matsuo
shift_evolve
0
140
Assisted reorganization of data structures
ennael
PRO
0
200
kube-vipとkube-proxy置き換えCiliumを積んだ究極のK3sクラスタを建てる
logica0419
3
180
Oracle GoldenGate 23ai 導入Tips
oracle4engineer
PRO
1
190
Consoles, printk, Nested-NMIs_ Oh my!
ennael
PRO
0
150
【shownet.conf_】多様化するネットワーク環境を柔軟に統合するルーティングテクノロジー
shownet
PRO
0
270
Pythonを活用したLLMによる構造的データ生成の手法と実践
brainpadpr
2
190
Featured
See All Featured
The Mythical Team-Month
searls
218
43k
For a Future-Friendly Web
brad_frost
174
9.3k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.2k
What's in a price? How to price your products and services
michaelherold
243
11k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
109
6.9k
Building Flexible Design Systems
yeseniaperezcruz
326
38k
Optimizing for Happiness
mojombo
375
69k
Agile that works and the tools we love
rasmusluckow
327
21k
Design by the Numbers
sachag
277
19k
Building Better People: How to give real-time feedback that sticks.
wjessup
359
19k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
32k
Transcript
Firestoreͷϧʔϧઃఆ ׂͱԿͰग़དྷͯϏϏΔ גࣜձࣾRe:Build Յ ါىʢ@kkznchʣ 20195݄17ʢۚʣ WebφΠτٶ࡚ Vol.4 ʙͯ͛FirebaseΛֶͼ͍ͨʙ
͚͚ͣΜ @kkznch Յ ါى 1990ͷԭೄੜ·Ε ిྗձࣾͷITΠϯϑϥɺηΩϡϦςΟ ↓ גࣜձࣾRe:BuildͰWebΤϯδχΞ
ձࣾհ • גࣜձࣾRe:Buildʢ201711݄ʹઃཱʣ • ݱࡏͷࣾһ໊̑ • ԭೄΛڌͱ͠ɺجຊతʹLaravelVue.jsΛ ͬͯडୗɾࣗࣾαʔϏε։ൃΛ͍ͯ͠Δ • ϦϞʔτϫʔΫɺࣗ༝ͳಇ͖ํΛਪ͍ͯ͠Δ
Firestore
Google͕ఏڙ͢ΔNoSQL DB
֊ܕσʔλߏ ΞΫηεϧʔϧΛઃఆͰ͖Δ
͠ϧʔϧΛઃఆ͠ͳ͍ͱ…
Databaseͷϧʔϧ
֊͝ͱʹϧʔϧΛద༻ usersͱɺͦͷதͷimagesʹ ରͯͦ͠ΕͧΕϧʔϧΛద༻Ͱ͖Δ service cloud.firestore { match /databases/{database}/documents { match
/users/{userId} { // rules… match /images/{imageId} { // rules… } } } }
֊ҎԼશͯʹϧʔϧΛద༻ service cloud.firestore { match /databases/{database}/documents { match /{users=**} {
// rules… } } } usersͱͦͷԼҐશͯʹϧʔϧΛద༻
allowϧʔϧྫ̍ʢςετ༻ʣ service cloud.firestore { match /databases/{database}/documents { match /{document=**} {
allow read, write: if true; } } } υΩϡϝϯτશମʹৗʹread, writeΛallow͢ΔΑ
allowϧʔϧྫ̎ service cloud.firestore { match /databases/{database}/documents { match /{document=**} {
allow read, write: if request.auth != null; } } } ϩάΠϯ͍ͯ͠ΔͳΒread, writeΛallow͢ΔΑ
allowͷछྨ • read ‣ get ‣ list • write ‣
create ‣ update ‣ delete
request, resource ม • request ‣ ΫϥΠΞϯτ͔ΒͷϦΫΤετʹؔ ͢ΔใΛࢀরͰ͖Δ • resource
‣ ݱࡏͷDBͷঢ়ଶΛࢀরͰ͖Δ
get(), exists() ϝιου • get() ‣ Ҿʹ༩͑ͨύε͔ΒΦϒδΣΫτ Λऔಘ͢Δ • exists()
‣ Ҿʹ༩͑ͨύεʹΦϒδΣΫτ͕ ଘࡏ͢Δ͔boolͰฦ͢
in ʹ͍ͭͯ • if x in y ‣ x͕ྻyʹؚ·Ε͍ͯΔ͔ΛνΣο Ϋ͢Δ
Έ߹ΘͤΔͱ͍͍ײ͡ʹͳΔ service cloud.firestore { match /databases/{database}/documents { function getRoom(roomId) {
return get(/databases/{database}/documents/rooms/{roomId}); } match /rooms/{roomId} { allow read, update: if request.auth != null && request.auth.uid in getRoom(roomId).data.users; } } } ྫɿϧʔϜϝϯόʔͰ͋Εread, update͕Ͱ͖Δ
·ͱΊ
·ͱΊ • FirestoreϦιʔεຖʹೝՄͷઃఆ͕Ͱ͖Δ • allow, function, request/resourceม, get()/ exists()ͳͲΛΈ߹Θͤͯࡉ͔͍ઃఆ͕Մೳ •
దʹϧʔϧΛઃఆͯ͠ใΛकΓ·͠ΐ͏