Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can i know what security firebase rule give me a error?

I have this firebase security rule:

".validate": "newData.val().length < 2"

When the new data.length is > 2, Firebase returns a error that says "PERMISSON_DENIED".

I would like to know if there is a way to get a error info like this "the new data is to long".

Thanks

like image 787
ayoseturru Avatar asked Feb 07 '16 10:02

ayoseturru


People also ask

What are firebase security rules?

Firebase Security Rules stand between your data and malicious users. You can write simple or complex rules that protect your app's data to the level of granularity that your specific app requires.

Does Firebase have an API key?

Firebase uses API keys only to identify your app's Firebase project to Firebase services, and not to control access to database or Cloud Storage data, which is done using Firebase Security Rules. For this reason, you do not need to treat API keys for Firebase services as secrets, and you can safely embed them in client code.

What is the difference between Cloud Firestore security rules and realtime database rules?

Firebase Realtime Database Rules leverage JSON in rule definitions, while Cloud Firestore Security Rules and Firebase Security Rules for Cloud Storage leverage a unique language built to accommodate more complex rules-specific structures.

How do I authenticate with Firebase services?

If you already have a secure sign-in system, whether a custom system or a third-party service, you can use your existing system to authenticate with Firebase services. Create custom JWTs from a trusted environment, then pass the tokens to your client, which uses the token to authenticate ( iOS+ , Android, Web , Unity, C++ ).


1 Answers

Firebase security rules return the same error, no matter what part failed. You have no control over the error message. If you're troubleshooting why an operation is failing, you can use the Simulator in your Firebase dashboard. But that doesn't seem what you're looking for.

Showing a more intelligent error message to the user is a great idea though. But I'd recommend doing that by validating the data before you send it to Firebase. So perform client-side validation and only send the data to Firebase if it passes the validation.

Better yet: don't allow the user to enter more than 2 characters.

like image 144
Frank van Puffelen Avatar answered Oct 11 '22 20:10

Frank van Puffelen