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
720
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
700
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
610
Laravel5.5的 継続的インテグレーション / Laravel 5.5 Continuous Integration
kkznch
3
3.3k
Other Decks in Technology
See All in Technology
rootlessコンテナのすゝめ - 研究室サーバーでもできる安全なコンテナ管理
kitsuya0828
3
380
Engineer Career Talk
lycorp_recruit_jp
0
160
ExaDB-D dbaascli で出来ること
oracle4engineer
PRO
0
3.8k
RubyのWebアプリケーションを50倍速くする方法 / How to Make a Ruby Web Application 50 Times Faster
hogelog
3
940
Introduction to Works of ML Engineer in LY Corporation
lycorp_recruit_jp
0
110
Terraform CI/CD パイプラインにおける AWS CodeCommit の代替手段
hiyanger
1
240
スクラム成熟度セルフチェックツールを作って得た学びとその活用法
coincheck_recruit
1
140
Amazon CloudWatch Network Monitor のススメ
yuki_ink
1
200
Security-JAWS【第35回】勉強会クラウドにおけるマルウェアやコンテンツ改ざんへの対策
4su_para
0
180
【Startup CTO of the Year 2024 / Audience Award】アセンド取締役CTO 丹羽健
niwatakeru
0
990
[FOSS4G 2024 Japan LT] LLMを使ってGISデータ解析を自動化したい!
nssv
1
210
Oracle Cloud Infrastructureデータベース・クラウド:各バージョンのサポート期間
oracle4engineer
PRO
28
12k
Featured
See All Featured
Measuring & Analyzing Core Web Vitals
bluesmoon
4
120
Side Projects
sachag
452
42k
RailsConf 2023
tenderlove
29
900
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Code Review Best Practice
trishagee
64
17k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
410
Music & Morning Musume
bryan
46
6.2k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Documentation Writing (for coders)
carmenintech
65
4.4k
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()ͳͲΛΈ߹Θͤͯࡉ͔͍ઃఆ͕Մೳ •
దʹϧʔϧΛઃఆͯ͠ใΛकΓ·͠ΐ͏