Firestoreのセキュリティルールで、
emailなどのUID以外を利用したいと思ったときに、
調べたときの備忘録。
request.auth.token.*を使えばOKっぽい。
使い方
こんな感じ。
service cloud.firestore {
match /databases/{database}/documents {
function isEmailVerified() {
return request.auth.token.email_verified == true;
}
match /foo/{uid} {
allow read, write: if isEmailVerified();
}
match /bar/{email} {
allow read, write: if request.auth.token.email == email;
}
match /{document=**} {
allow read, write: if false;
}
}
}
他の値は、以下の公式ドキュメントを参照。
・Interface: Request | Firebase
以上!!