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
290
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.6k
Other Decks in Technology
See All in Technology
Fabric + Databricks 2025.6 の最新情報ピックアップ
ryomaru0825
1
150
MySQL5.6から8.4へ 戦いの記録
kyoshidaxx
1
290
2025-06-26 GitHub CopilotとAI駆動開発:実践と導入のリアル
fl_kawachi
1
210
GeminiとNotebookLMによる金融実務の業務革新
abenben
0
240
開発生産性を組織全体の「生産性」へ! 部門間連携の壁を越える実践的ステップ
sudo5in5k
0
170
Connect 100+を支える技術
kanyamaguc
0
110
自律的なスケーリング手法FASTにおけるVPoEとしてのアカウンタビリティ / dev-productivity-con-2025
yoshikiiida
0
210
KubeCon + CloudNativeCon Japan 2025 Recap
ren510dev
1
280
Oracle Audit Vault and Database Firewall 20 概要
oracle4engineer
PRO
3
1.7k
生成AI開発案件におけるClineの業務活用事例とTips
shinya337
0
160
PHP開発者のためのSOLID原則再入門 #phpcon / PHP Conference Japan 2025
shogogg
4
910
Yamla: Rustでつくるリアルタイム性を追求した機械学習基盤 / Yamla: A Rust-Based Machine Learning Platform Pursuing Real-Time Capabilities
lycorptech_jp
PRO
4
160
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
46
9.6k
Bash Introduction
62gerente
614
210k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
5
230
Music & Morning Musume
bryan
46
6.6k
We Have a Design System, Now What?
morganepeng
53
7.7k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
The World Runs on Bad Software
bkeepers
PRO
69
11k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.8k
Automating Front-end Workflow
addyosmani
1370
200k
[RailsConf 2023] Rails as a piece of cake
palkan
55
5.6k
Site-Speed That Sticks
csswizardry
10
670
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 དྷ݄̎ճ։࠵ʂੋඇ༡ͼʹདྷ͍ͯͩ͘͞ʂ
͋Γ͕ͱ͏͍͟͝·ͨ͠ʂʂ