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
Firebaseはロックに使おう / Netadashi Meetup#8 Firebase
Search
w2-yamaguchi
January 18, 2019
Technology
1
240
Firebaseはロックに使おう / Netadashi Meetup#8 Firebase
Netadashi Meetup#8 LT資料
2019.01.18 @みなとみらい
w2-yamaguchi
January 18, 2019
Tweet
Share
More Decks by w2-yamaguchi
See All by w2-yamaguchi
AWSを活用して社内ISUCONを開催したはなし
watarukun
5
2.3k
Other Decks in Technology
See All in Technology
私が trocco を推す理由
__allllllllez__
1
220
オーナーシップを持つ領域を明確にする
konifar
13
3.2k
JAWS-UG Bedrock Claude Night
yamahiro
3
610
LayerXにおけるLLMプロダクト開発の今までとこれから
layerx
PRO
1
300
検証を通して見えてきたTiDBの性能特性
lycorptech_jp
PRO
6
3.8k
VS CodeでAWSを操作しよう
smt7174
8
1.7k
LangSmith入門―トレース/評価/プロンプト管理などを担うLLMアプリ開発プラットフォーム
os1ma
3
170
サーバー間 GraphQL と webmock-graphql の話 / server-to-server graphql and webmock-graphql
qsona
2
190
IaCジェネレーターとBedrockで詳細設計書を生成してみた
tsukasa_ishimaru
1
210
ExaDB-D dbaascli で出来ること
oracle4engineer
PRO
0
2.1k
現代CSSフレームワークの内部実装とその仕組み
poteboy
7
3.6k
JSON攻略法.pdf
miyakemito
8
5k
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
6
1.5k
Git: the NoSQL Database
bkeepers
PRO
422
63k
Reflections from 52 weeks, 52 projects
jeffersonlam
345
19k
Designing on Purpose - Digital PM Summit 2013
jponch
110
6.5k
Music & Morning Musume
bryan
41
5.6k
Fireside Chat
paigeccino
21
2.6k
Building an army of robots
kneath
300
41k
The Brand Is Dead. Long Live the Brand.
mthomps
49
29k
How GitHub Uses GitHub to Build GitHub
holman
468
290k
Code Reviewing Like a Champion
maltzj
514
39k
What the flash - Photography Introduction
edds
64
11k
GraphQLの誤解/rethinking-graphql
sonatard
50
9.2k
Transcript
FirebaseʮϩοΫʯʹ͓͏ 2019/1/18, Netadashi Meetup#8 w2-yamaguchi
ࣗݾհ • w2-yamaguchi • 2015ೖࣾ • େखอݥձ͚ࣾͷγεςϜ։ൃʹैࣄ • Firebase Japan
User Group ӡӦ 2 ayubuki
ͳ͢͜ͱ! • FirebaseΛ͏্Ͱ͓͍ͬͯͯཉ͍͜͠ͱ • ܒతͳͳ͠ 3 ͳ͞ͳ͍͜ͱ" • ٕज़తͳࡉ͔͍ͳ͠
FirebaseͷαʔϏε͜Μͳʹ͍ͬͺ͍ʂ 4 Crashlytics Performance Monitoring Test Lab Cloud Firestore ML
Kit Cloud Functions Authentication Hosting Cloud Storage Realtime Database In-App Message Google Analytics Prediction A/B Testing Cloud Messaging Remote Config Dynamic Links App Indexing Build better apps Improve app quality Grow your business ※2019/1/15ʹެࣜϓϩμΫτϖʔδʢhttps://firebase.google.comʣΑΓൈਮ
FirebaseͷαʔϏε͜Μͳʹ͍ͬͺ͍ʂ 5 Crashlytics Performance Monitoring Test Lab Cloud Firestore ML
Kit Cloud Functions Authentication Hosting Cloud Storage Realtime Database In-App Message Google Analytics Prediction A/B Testing Cloud Messaging Remote Config Dynamic Links App Indexing Build better apps Improve app quality Grow your business ※2019/1/15ʹެࣜϓϩμΫτϖʔδʢhttps://firebase.google.comʣΑΓൈਮ ࠓ͜͜Λ͠·͢ʂ
Cloud FirestoreΛͬͨ͜ͱ͕͋Δਓ 6
Cloud Firestoreͷಛ • ॊೈੑ • ߴػೳͳΫΤϦॲཧ • ϦΞϧλΠϜɹΞοϓσʔτ • ΦϑϥΠϯαϙʔτ
• ֦ுੑͷ͋Δઃܭ 7 ※ެࣜυΩϡϝϯτʢhttps://firebase.google.com/docs/firestoreʣΑΓൈਮ
Cloud Firestoreͷߏ • Cloud Firestore NoSQLσʔλϕʔε • PCͷϑΝΠϧγεςϜͷΑ͏ͳߏΛ࣋ͭ͜ͱ͕Ͱ͖Δ 8 {
"users": { ”user001": { "name": ”user001", "email": ”
[email protected]
" }, ”user002": { "name": ”user002", "email": "
[email protected]
" } } } collection document data
֤ΫϥΠΞϯτ͔ΒಡΈॻ͖Ͱ͖Δ • WebɺAndroidɺiOSɺUnity͔ΒɺಡΈॻ͖͢Δ͜ͱ͕ Ͱ͖Δ 9 SDK
Cloud FirestoreͷηΩϡϦςΟػߏ • υΩϡϝϯτ୯Ґʹಠࣗͷݴޠ*1ͰΫϥΠΞϯτ͔ΒͷΦϖ Ϩʔγϣϯ*2Λ੍ޚ͢Δ 10 service cloud.firestore { match
/databases/{database}/documents { match /<some_path>/ { allow read, write: if <some_condition>; } } } Basics Details Authorization read get ୯ҰυΩϡϝϯτͷಡΈࠐΈݖݶ list ΫΤϦ͓ΑͼίϨΫγϣϯͷಡΈࠐΈݖݶ write create ଘࡏ͠ͳ͍υΩϡϝϯτͷ࡞ݖݶ update ଘࡏ͢ΔυΩϡϝϯτͷߋ৽ݖݶ delete ଘࡏ͢ΔυΩϡϝϯτͷআݖݶ *1 ಠࣗݴޠʹΑΔϧʔϧͷهड़ *2 ੍ޚͰ͖ΔΦϖϨʔγϣϯ
Cloud Firestoreͷਏ͍ͱ͜Ζ • ηΩϡϦςΟϧʔϧ͕ΊΜͲ͍͘͞ • ΫΤϦ͕ශऑʢࠓ͞ͳ͍ʣ 11
Γ͕ͪͰ͢ΑͶɻɻɻʁ 12
69%ͷਓ͕ςετϞʔυͰ࢝ΊͯΔ ʣݸਓௐ 13 ςετϞʔυ ϩοΫϞʔυ Twitter্ͷΞϯέʔτʹΑΔௐࠪ݁Ռʢճਓɿ55໊ʣ https://twitter.com/ayubuki/status/1085164645441187840
合計1億件以上の個人情報がFirebaseの脆 弱性によって公開状態に ݪจʣ62% of Enterprises Exposed to Sensitive Data Loss
via Firebase Vulnerability - Appthority 14 https://gigazine.net/news/20180625-firebase-vulnerability-data-loss/ https://www.appthority.com/company/press/press-releases/62-of-enterprises-exposed-to-sensitive-data-loss-via-firebase-vulnerability/
合計1億件以上の個人情報がFirebaseの脆 弱性によって公開状態に ݪจʣ62% of Enterprises Exposed to Sensitive Data Loss
via Firebase Vulnerability - Appthority 15 https://gigazine.net/news/20180625-firebase-vulnerability-data-loss/ https://www.appthority.com/company/press/press-releases/62-of-enterprises-exposed-to-sensitive-data-loss-via-firebase-vulnerability/ ʜηΩϡϦςΟձࣾͷ"QQUIPSJUZʹΑΔͱɺ͜ͷ੬ऑੑ Firebaseσʔλϕʔεͷೝূ͕దʹߦΘΕ͍ͯͳ͍ ͱ͖ʹݦࡏԽ͢Δͷɻୈ࢛ظʹݟ͔ͭͬͨɺ ΞϓϦ։ൃऀʹΑΔσʔλ֨ೲͷอޢ͕ෆશͳͱ͖ ʹใ͕࿐ग़ͯ͠͠·͏ʮ)PTQJUBM(PXOʯͱݺΕΔ੬ऑੑ ͷมछͰ͋Δͱߟ͑ΒΕ͍ͯ·͢ɻใΛ࿙Β͍ͯ͠Δʮ੬ऑ ͳΞϓϦʯΛ๊͑Δاۀগͳ͘ͱར༻ऀͷˋʹ্ΔͱΈ ΒΕͯʜʢൈਮʣ
ͭ·Γ͜͏͍͏͜ͱ ʣࢲݟ 16 service cloud.firestore { match /databases/{database}/documents { match
/{document=**} { allow read, write; } } } service cloud.firestore { match /databases/{database}/documents { match /{document=**} { allow read, write: if request.auth.uid != null; } } } ୭ͰಡΈॻ͖Ͱ͖ΔʢʹςετϞʔυͰ։࢝ʣ ೝূࡁΈϢʔβʔಡΈॻ͖Ͱ͖Δ
ͬͯ΄͍͜͠ͱʂ ʬϒϥοΫϦετܕରࡦʭ Φʔϓϯঢ়ଶʢςετϞʔυʣ͔ΒͲ͏ߜ͍͔ͬͯ͘ߟ͑Δ ʬϗϫΠτϦετܕରࡦʭ Ϋϩʔζঢ়ଶʢϩοΫϞʔυʣ͔ΒͲ͏؇Ί͍͔ͯ͘ߟ͑Δ 17
Tipsʣ υΩϡϝϯτʹύʔϛογϣϯΛ༩ υΩϡϝϯτʹެ։ใ͔Ͳ͏͔அ͢ΔύʔϛογϣϯΛ ࣋ͨͤΔ 18 service cloud.firestore { match /databases/{database}/documents
{ match /items/{itemID} { allow read: if resource.data.isPublic == true || request.auth.uid == resource.data.uid; allow write: if request.auth.uid == resource.data.uid; } } } items item001 title: pizza isPublic: true item002 title: pasta isPublic: false ެ։ใͷΈ શһ͕ࢀরՄೳ
19 Tipsʣެ։ใͱൿಗใͷ ϧʔτϨϕϧͷίϨΫγϣϯͰެ։ใͱൿಗใΛ͚Δ service cloud.firestore { match /databases/{database}/documents { match
/users/{userID} { allow read: if request.auth.uid != null; allow write: if request.auth.uid == resource.data.uid; } match /_users/{userID} { allow read, write: if request.auth.uid == resource.data.uid; } } } users _users user001 name: Bob twitter: bobbob uid: AEvO…T3hG birth: 1992/06/14 mail: bob@example uid: AEvO…T3hG ϢʔβࣗͷΈ ࢀরɺߋ৽Մೳ user001
20
FirebaseʮϩοΫʯʹ͓͏ʂ 21 Firestore
Firebase Japan User GroupͷΠϕϯτ 2/6 Firebase Meetup #10 @mercari -GDEͷ2ਓ͕TestLabͱFirestoreʹ͍ͭͯޠΓ·͢ʂ
2/18 Firebase Meetup #11 @navitime 22 ࠂ https://firebase-community.connpass.com དྷ݄̎ճ։࠵ʂੋඇ༡ͼʹདྷ͍ͯͩ͘͞ʂ
͋Γ͕ͱ͏͍͟͝·ͨ͠ʂʂ