3

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.

1
  • userId == asdfasfasdf does not make sense. To give access to admins, you would need something like request.auth.uid == 'adminuid', where adminuid is the UID of your admin user. Commented Apr 2, 2018 at 21:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.