Home > other >  Firebase Change Permissions Public Access SwiftUI
Firebase Change Permissions Public Access SwiftUI

Time:11-09

I am using Firebase for Auth and image storage--images that are publically available thoughout my app, like profile pictures. How do I set up the permissions appropriately so that any user (or even non-authenticated entities) can read these public images?

My security rules:

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

CodePudding user response:

In your question, you say that you want non-authenticated entities to see the images, but your rules are set up to only allow authenticated entities to see them. You can change your rules to:

service firebase.storage {
    match /b/{bucket}/o {
        match /{allPaths=**} {
            allow read; 
            allow write: if request.auth != null;
        }
    }
 }
  • Related