Firebase StorageのRule
マッチしたパスに対してリクエストTokenの属性などからread, writeなど権限を操作出来る
code:rule
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
// admin user can read, write any documents
match /{allPaths=**} {
allow read, write:
if request.auth.token.get("foobar", false) == true;
allow read, write:
if request.auth.token.get("foobarbaz", false) == true;
}
match /{collection}/{version}/{subcollection}/{userId}/{allPaths=**} {
allow read, write:
if request.auth.uid == userId;
}
}
}
matchしたパスをplaceholderとして使いリクエストのユーザIDがパスに一致しているかなどで所有者チェックなどを行える
code:rule
match /{collection}/{version}/{subcollection}/{userId}/{allPaths=**} {
allow read, write:
if request.auth.uid == userId;
}