Skip to content

Instantly share code, notes, and snippets.

@JosephineAkello
Last active February 4, 2023 23:45
Show Gist options
  • Save JosephineAkello/69bac1a5381a3160f40dcd6d129aaed7 to your computer and use it in GitHub Desktop.
Save JosephineAkello/69bac1a5381a3160f40dcd6d129aaed7 to your computer and use it in GitHub Desktop.
Firebase stripe security rules
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function hasBasicSubs() {
return request.auth.token.stripeRole == "basic";
}
function hasPremiumSubs() {
return request.auth.token.stripeRole == "premium";
}
match /content-basic/{doc} {
allow read: if hasBasicSubs() || hasPremiumSubs();
}
match /content-premium/{doc} {
allow read: if hasPremiumSubs();
}
match /customers/{uid} {
allow read: if request.auth.uid == uid;
match /checkout_sessions/{id} {
allow read, write: if request.auth.uid == uid;
}
match /subscriptions/{id} {
allow read: if request.auth.uid == uid;
}
}
match /products/{id} {
allow read: if true;
allow write: if false;
match /prices/{id} {
allow read: if true;
allow write: if false;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment