Firebase Storage with Firestore rules - 403 unauthorized

107 views
Skip to first unread message

Medaillek

unread,
Sep 1, 2023, 12:22:05 PM9/1/23
to Firebase Google Group
Hello,

I have an issue accessing Storage with rules when using firestore.get().

I have these rules :
service firebase.storage {
  match /b/{bucket}/o {
  match /private/{allPaths=**} {
allow read : if firestore.get(/databases/(default)/documents/utilisateurs/$(request.auth.uid)).data.subscriptionLevel == 1
  }
  match /thumbnails/{allPaths=**} {
  allow read: if request.auth != null
  }
}
}


And I'm unable to get access to the folder private with all it's children.

My firestore looks like :
A user collection : "utilisateurs"
Documents : "auth.uid"
And inside the document I have a subscriptionLevel field which takes 0 or 1.

Since 2 days I'm trying to make it work by removing data, changing collection name but nothing is working.

If someone knows why I always get unauthorized even if my document has a 1 set in subscriptionLevel.

Thanks
Reply all
Reply to author
Forward
0 new messages