问题
Is is possible to include a payload/parameter when executing a GET request to Firebase Realtime Database, in order to access the payload/parameter in the Firebase Realtime Database rules?
Using React Native with Javascript.
回答1:
For a GET/read request to the Realtime Database, the following information is available in your security rules:
- The path that is requested, or the query that was executed.
- The auth variable indicating the logged in user, including any claims in auth.token.
So if you want to pass information, you will have to put it into one of these. For example, you can make the payload part of the path, or you can store it in the user's profile as a custom claim.
Putting in the path is typically preferred for short-lived information, like a nonce or a shared secret, while a custom claim is more common for some semi-permanent state of the users, such as them being marked as an application administrator.
来源:https://stackoverflow.com/questions/65993204/firebase-database-sending-payload-with-rest-request