-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Firestore And Storage Security Rules for Flamelink projects. #86
Comments
Hi @ribalnasr Thanks so much for doing this. I'm sure other users will also find this useful. I'll see where we can add this to our documentation. |
@ribalnasr - thanks for this awesome work. Would love to implement it in my solution. Currently however - if I implement these security rules I am unable to edit from flamelink CMS, as no permissions are set from there. How would I implement to have it work there as well? |
Amazing work, guys. I've included this in one of the Flamelink articles for other developers to reference: https://intercom.help/flamelink/en/articles/3068550-flamelink-and-cloud-firestore |
lovely update @Danelund , this is is exactly what i was trying to achieve without using custom claims but i couldn't at the time... i remember your updated code was here in this thread before but its not now.. please update the docs as the current ones do not allow creating new schemas or updating existing entries from the flamelink cms. PS: It would be perfect if the guest profile is automatically created upon creating the project in flamelink cms. here's the updated code:
|
Thanks a million! I have updated the article with the latest code updates. |
@ribalnasr - excellent idea! Next step in improving the rules would be to evaluate [env], as currently they only set permissions for the production environment. |
hello people! :) under update the delete action to be resource instead of request.resource. @Danelund thank you and i agree about environment, i personally can't work on it soon so please feel free to update it peace. |
Thank you so much for continuously updating this! As for the guest user suggestion, I will table it, but I think because we are limited to the number of users on the payment plans this might be possible right now. |
a guest and a sudo profile within the free plan.. just a thought :) |
It would not be too difficult to add a guest permission group with only read/view permissions. |
What is the best way to secure content to the user who created the content? |
Hi, I am trying to login to my Flamelink, after I updated Firestore rules for my app. I added your rules and in test (Rules Playground), everything is OK / passed. But when I try to login to Flamelink Dashboard, access is denied. Honestly, I don't understand why - I removed the global rule for "deny all", bcs in default (without a match) is all denied. It seems that in these rules is something missing. If I use "allow all" global rule, the login works fine. I also tried to just allow read & write for all |
hey @YariKoen, in the firebase console, inside firestorm, find your user under fl_users, does it have permissions = fl_permissions/1 ? |
@ribalnasr yea, there are two doc's in |
the problem seems to be there, change the one with a string value to a reference on 'fl_permissions/1', and check the user uid under authentication then compare it to the ids in the fl_users collection. delete the duplicated user with the wrong id. |
@ribalnasr It works, thanks! 🎉 |
Hi @ribalnasr, We have a user who has implemented the rules and mentioned that they are unable to log in, so I tried to replicate the issue and found that the emulator does give an error. the user permissions is a reference
The function that is giving an error 👇 function userPermissions(){
return get(get(/databases/$(database)/documents/fl_users/$(request.auth.uid)).data.permissions).data
} I have tried to see if the following works function getPermissionValue(r) {
// return get(rel).data // 1
// return get(rel.path).data // 2
// return get(get(/databases/$(database)/documents/fl_permissions/$(r.id)).data // 3
// return get(get(/databases/$(database)/documents/$(r.path)).data // 4
return get(/databases/$(database)/documents/fl_permissions/LXmaoasdp1).data // sanity check - works.
}
function userPermissions(){
return getPermissionValue(get(/databases/$(database)/documents/fl_users/$(request.auth.uid)).data.permissions))
} From what I can tell the rules does not allow for a reference value. |
hi @gitdubz, sorry for the late reply.. the error here seems to be that the result of the first get() (the inner one) does not return a valid document on the permissions field, hence the parent get() function is unable to work. are we sure the user.permissions reference refers to an existing document? i have noticed sometimes that the default permissions field for the sudo user when starting a new flamelink project is [object Object] for some reason instead of a path to document reference and i had to change this manually. could that be the case? |
Thanks @ribalnasr, The document in question is a reference, I even created on manually to make sure. |
i might be able to assist you further if it's possible to have access to the firebase project. let me know if i can help. |
Hi,
I've been working on a set of rules for Flamelink that i'd love to share with you.
Forgive me if it's not the right place for it, and feel free to move it to where it belongs.
EDITED: Find firestore updated rules below
The text was updated successfully, but these errors were encountered: