Reputation: 83828
I want to verify that Firebase Storage rules are working as expected with automated Node.js tests.
One can access Firebase Storage buckets with the Firebase Admin API or a service account, as indicated in Upload files to Firebase Storage using Node.js.
The problem is that using the Admin API or a service account circumvents the storage rules.
There is no apparent way to access Firebase Storage as a given Firebase user, as the Firebase Node.js API does not include a firebase.storage
function.
In short, how can one access Firebase Storage from Node.js as a given Firebase user/uid?
Upvotes: 4
Views: 975
Reputation: 599716
As far as I know there is currently no way to accomplish what you want.
There is a storage()
service in the Firebase Admin SDK for Node.js, but as you've discovered this gives full administrative access to your bucket.
While the Admin SDK for the Realtime Database can be initialized to access the database as a specific user, this feature is not available for the Storage service.
What you want to do sounds quite reasonable though, so I recommend that you file a feature request. In the meantime, the best I can think of is running those unit tests in a browser, so that you can authenticate with the regular JavaScript client SDK.
Upvotes: 5