-- UPDATE --
It turns out the below should have worked, but didn't due to a bug, so this was recommended by Firebase Support as a workaround, and it worked for me:
request.auth.token.permissions.toSet().hasAll([0])
-----------------------------
I have an array/list of with a single integer on my custom claims like this:
someList: [0]
I want to check if a number exists in the list in my storage security rules. I can't seem to get the hasAll
rule to work that is mentioned in the documentation: https://firebase.google.com/docs/reference/security/storage#hasall
Some rules work when referencing the list so I know for sure that the property is there in my custom claims, but I can't seem to get it to work with hasAll
or using tricks with strings.
Example -
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /clients/{clientId}/{allPaths=**} {
// These work -
allow read, write: if request.auth.token.someList.join('').size() > 0
allow read, write: if request.auth.token.someList != null
// These do not -
allow read, write: if request.auth.token.someList.hasAll([0])
allow read, write: if request.auth.token.someList.join('').matches('0')
}
}
}
♂️ ?