0

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 Answer 1

1

For a GET/read request to the Realtime Database, the following information is available in your security rules:

  1. The path that is requested, or the query that was executed.
  2. 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.

Sign up to request clarification or add additional context in comments.

10 Comments

Thanks for the answer! Regarding the first option, how do I access the variables in the database rules? For instance, if my path is "firebaseurl/auth?={token}?variable={variableValue}, how do i access the value of the variable in the database rules?
There is no way to pass a custom variable to the rules. The only two options are mentioned in my answer.
So I should use queries? Sorry, i am not very into rules. Is it possible to pass a custom variable by using queries?
It isn't possible to pass a custom variable into queries. The only information that your rules have is what I've listed in my answer.
How is it then possible to check a parameter that the user performing the request sets, up against a value in the database? To ensure secure read / write rules.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.