apod
apod

Reputation: 19

read only firebase storage rules tab

I would like to set the rules tab of my firebase object to read only.

When I take off the write parcel I got an error on my python when trying to add files to my storage.

Below is my code

import firebase_admin

config={
    "apiKey": "xxx",
    "authDomain": "xxx",
    "databaseURL": "xxx",
    "projectId": "xxx",
    "storageBucket": "xxx",
    "messagingSenderId": "xxx",
    "appId": "xxx",
    "measurementId": "xxx"
}
# Initialize connection to firebase_admin

firebase = firebase_admin.initialize_app(config)
storage = firebase.storage()

path_on_cloud ="Data quality report/Data quality report.py"
path_local = "Data_quality_report.py"
storage.child(path_on_cloud).put(path_local)

My rules tab is

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

Do you guys know how to fix this problem?

Thank you in advance

Upvotes: 1

Views: 250

Answers (1)

Shardul Nalegave
Shardul Nalegave

Reputation: 409

Don't initialize it that way! You are using the firebase_admin package which using the Firebase Admin SDK. To initialize it create a new service account key file which is then used for initializing.

Admin does what it sounds like it would do. It has all privileges.

Refer the official docs for proper explanation on setup. (I am really bad at explaining things). https://firebase.google.com/docs/storage/admin/start#python

Upvotes: 2

Related Questions