Last active
February 4, 2023 23:45
-
-
Save JosephineAkello/69bac1a5381a3160f40dcd6d129aaed7 to your computer and use it in GitHub Desktop.
Firebase stripe security rules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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