Firebase Simulated and actual rules differ -
i using firebase realtime database , query data firebase-query , firebase-document. configured rules, when ran in simulator read accepted in real life read id denied. have ".read": true in root expected outcome. note: using both polymerfire , firebase js sdk different things , js on external file , writing rules using bolt compiler.
rules:
rules.bolt
//questions path /question/{qid} { read() { true } write() { true} } //users path /users/{uid}/profile { read() { true } write() { signedin() && isuser(auth, uid) } } path /users/{uid}/metadata { read() { signedin() && isuser(auth, uid) } write() { signedin() && isuser(auth, uid) } } function signedin (){ auth != null} function isuser (auth, userkey) { return auth.uid == userkey; } rules.json
{ "rules": { "question": { "$qid": { ".read": "true", ".write": "true" } }, "users": { "$uid": { "profile": { ".read": "true", ".write": "auth != null && auth.uid == $uid" }, "metadata": { ".read": "auth != null && auth.uid == $uid", ".write": "auth != null && auth.uid == $uid" } } } } } expectation
stored value initialised , data can read questons/{{qid}} , users/{{uid}}/profile (and users/{{uid}}/metadata if user seeing him/hers won profile) , data shown.
reality
when not used ".read": true:
initializing stored value. and no data incoming though when ran in simulator read granted.
when used ".read": true:
initializing stored value. sync memory. updating data firebase value: {metadata: {…}, profile: {…}} got stored value! {metadata: {…}, profile: {…}} {metadata: {…}, profile: {…}} sync memory. and other datas incoming , showing.
i think because of rules cascade.
if rules cascade case how fix using bolt , if not do?
Comments
Post a Comment