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
710
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
360
VueRouterとNuxtのルーティング/VueRouter and Nuxt Routing
kkznch
0
320
Vuexで何を管理する方が良い?/What is better to store in Vuex?
kkznch
1
690
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
1.1k
Laravel Novaはなんだかいい感じらしい/Laravel Nova seems to be nice
kkznch
0
600
Laravel5.5的 継続的インテグレーション / Laravel 5.5 Continuous Integration
kkznch
3
3.3k
Other Decks in Technology
See All in Technology
Application Signalsで始めるSLO ユーザー満足度を数値化する第一歩
niftycorp
PRO
2
140
RAG: from dumb implementation to serious results
glaforge
0
640
太田博三(@usagisan2020)
otanet
0
150
寒冷地稲作の歴史にみるコミュニティ
miu_crescent
2
140
マルチテナントのサービスインフラに大きなテナントを受け入れるまで
7474
0
720
テストを楽に書きたい
tomorrowkey
2
270
Covariance, Contravariance & Diamond
alexdaubois
1
110
Delta Commit…の最近...
akuwano
2
120
Vue.js、Nuxtの機能を使い、 大量のコピペコードをリファクタリングする
igayamaguchi
3
1k
フェンリルの SwiftUI の研修を覗いてみる / Fenrir SwiftUI Training
studio_rookery
0
150
XSS攻撃から考察するAWS設定不備の恐怖/20241012 Hironobu Otaki
shift_evolve
0
130
入社半年(合計1年)でGoogle Cloud 認定を全冠した秘訣🤫
risatube
1
270
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
A better future with KSS
kneath
237
17k
The Invisible Side of Design
smashingmag
297
50k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
We Have a Design System, Now What?
morganepeng
50
7.2k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Typedesign – Prime Four
hannesfritz
39
2.4k
[RailsConf 2023] Rails as a piece of cake
palkan
49
4.8k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
228
52k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
5
130
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
40
2.1k
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()ͳͲΛΈ߹Θͤͯࡉ͔͍ઃఆ͕Մೳ •
దʹϧʔϧΛઃఆͯ͠ใΛकΓ·͠ΐ͏