How can I grant read-write access based on custom parameters, for example, When a user is registered with my app, a document is created and the document id is used to create a folder in firebase storage(so that I can ensure the uniqueness if every folder in firebase storage) The rule I am setting is a read permission for everyone who is authenticated and the write access is only for the user who created it and the admin only. Here is the rule I presently have in firebase storage.
service firebase.storage {
match /b/{bucket}/o {
match /{userId}/{allPaths=**} {
allow read: if request.auth != null;
allow write:if request.auth.uid == userId || userId == asdfasfasdf
}
}
}
Is this approach correct or correct me if I am doing it wrong. I have gone through the documentation and it is a bit hard for me to understand.
userId == asdfasfasdfdoes not make sense. To give access to admins, you would need something likerequest.auth.uid == 'adminuid', whereadminuidis the UID of your admin user.