Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Firestoreのルール設定 割と何でも出来てビビる/Firestore rule setting

Firestoreのルール設定 割と何でも出来てビビる/Firestore rule setting

Webナイト宮崎 Vol.4
登壇枠で使用

参考URL
https://tegehoge.connpass.com/event/128502/

kkznch

May 17, 2019
Tweet

More Decks by kkznch

Other Decks in Technology

Transcript

  1. allowϧʔϧྫ̍ʢςετ༻ʣ service cloud.firestore { match /databases/{database}/documents { match /{document=**} {

    allow read, write: if true; } } } υΩϡϝϯτશମʹৗʹread, writeΛallow͢ΔΑ
  2. allowϧʔϧྫ̎ service cloud.firestore { match /databases/{database}/documents { match /{document=**} {

    allow read, write: if request.auth != null; } } } ϩάΠϯ͍ͯ͠ΔͳΒread, writeΛallow͢ΔΑ
  3. get(), exists() ϝιου • get() ‣ Ҿ਺ʹ༩͑ͨύε͔ΒΦϒδΣΫτ Λऔಘ͢Δ • exists()

    ‣ Ҿ਺ʹ༩͑ͨύεʹΦϒδΣΫτ͕ ଘࡏ͢Δ͔bool஋Ͱฦ͢
  4. ૊Έ߹ΘͤΔͱ͍͍ײ͡ʹͳΔ 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͕Ͱ͖Δ