nouhau
nouhau copied to clipboard
FirestoreでG Suiteのドメイン指定のセキュリティルールを設定する
WHAT
Firebase Auth for Googleを利用してログインし、Firestoreでドメイン指定を行いたい!
WHY
gcpug.jp
アカウント限定みたいなことをしたい
以下のような感じで、 request.email
を見てあげればよいっぽい
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if false;
}
match /users/{userId} {
allow create,delete,update: if request.auth.uid == userId && request.auth.token.email.matches('.*@gcpug[.]jp');
}
}
}
カスタムAuthでがんばるという手もある https://github.com/firebase/functions-samples/tree/master/instagram-auth