Firebase Storage: Setting Up Objects for Public Access

I have a small project using Firebase Storage service to serve some static files. By default, all files under a bucket are not accessible for public. To make files available for public access, we need to modify the rules.

In the following example, my bucket is called happybucket123.appspot.com, since I need to give public permission to read, this is what I have in my storage rule.

rules_version = '2';
service firebase.storage {
  match /b/happybucket123.appspot.com/o {
    match /{allPaths=**} {
        allow read;
        allow write: if request.auth != null;
    }
  }
} 

The above rule will keep the write access only for the authorised users.