Replies: 4 comments 9 replies
|
I wonder how developers are using the current Permissions in production -- do they have zero care for data integrity? I cannot see how I can get around rolling my own CRUD-functions for each Database and Storage request. This comes with a number of drawbacks, off the top of my head:
Wins:
It should probably be mentioned in the documentation if this is the expected usage, and if it is, maybe provide some tooling for it? I'm starting to structure my own tools for this now, but it does feel off reinventing the wheel and having to ignore entire Appwrite features.
I'm still doubting myself here, maybe I've missed something 😄 - are there better methods for this that I haven't considered? |
|
Hey there 👋 Your concerns are valid. We are actively discussing more server variables similar to As you mentioned, the best way to have a 100% secure solution as of right now is Appwrite Functions. What I usually do is one generic function that listens to all In the code, I look for specific attributes by name, and forcefully replace the value, but only if necessary. That way if the attacker set ID to value of another user, the function would very quickly correct that. This is pretty much the same solution that server variables would be, with the main difference being that it's async, and maintained by you. Another solution would be to use frontend rendering framework features, such as actions in Svelte Kit, or custom endpoints in Next.js. You can relay that those are executed on the server, and you can do server-side logic there as well. It will not only solve the security, but also bring in other advantages, such as server-side rendering, and possibly make your website work without JS. With that said, I still understand your frustration, and I agree this should be addressed. I shared this discussion with the team internally to get more feedback on the topic. |
|
Subscribing to the thread. We're thinking of improving this stuff in the next release (no promises). Thanks for brining this up! |
|
We have created a proposal to add optional server-defined attributes. Would appreciate your feedback here: https://github.com/appwrite/rfc/blob/31c148ccd053be17c9fe86866a92b8760876f824/021-server-defined-attributes.md |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Just got home from vacation and was excited to try out Appwrite, so I started building a small Twitter clone. I really enjoyed the ease of setup and vast scope of functionality! Unfortunately there's a heck-ton of great features that I didn't get to try out, as I got immediately put off by the lack of flexibility around
Permissions.It seems that it's more or less impossible to accomplish even basic things safely without introducing a custom backend, and in the end I will need to lock down every single client-facing API, reducing the usability of the web api to
read-only operations.Take for instance a very basic Twitter-clone,
Userhas exactly oneUserProfileUsersneed to be able to create oneUserProfile, and only for themselvesTweetsUsersneeds to be able to create manyTweets, but only for themselvesIn Firebase
Security Rules✅ The Security Rules can be set up so that users only have write access to a single UserProfile, which must be their own.
✅ The Security Rules can be set up so that they are only allowed to create "Tweets" with their own authed
idasTweet.owner.Reference: https://firebase.google.com/docs/firestore/security/rules-conditions
In Appwrite
Usersto createUserProfiles, we need to allow allUsersthe CREATE permission.Usersto create nthUserProfiles, and could supply anyownerid, which allows creatingUserProfilesfor anyUser.Usersto createTweets, we allow allUsersthe CREATE permission.Usersto createTweetswith anyownerid, which allows creatingTweetsfor anyUser.In order to mitigate this, we'll need to
CREATE, andUPDATEpermissions for bothTweetsandUserProfiles, andUPDATEpermission, a user can change theTweet.ownerafter creationbff(backend-for-frontend), or Appwrite Function, with document-fetching boilerplate, conditions, custom error messages, etc etcAlso, setting
document-levelpermissions in the client request is not really convenient imho. Not only is it unsafe and prone to error, it will cause a huge headache when conditions inevitably change ⏲️.I find the beauty of
Firebase(andPocketbase, andSupabaseto some extent), is that they let us utilize Storage and Database access permissions that essentially eliminate the need for any backend code - or a server at all for that matter. At least for simple applications!Is there further discussion around this topic? Are there any best practices around how to do this "the Appwrite way"?
Thanks!
Edit:
I did some further searching and found this, which essentially asks the same question as me:
#3705
The accepted "solution" is suggesting what I wrote above: essentially making your own C
RUD endpoints for every resource usingAppwrite Functions. I'm not really satisfied with this answer 😞. This will be required by every project that uses the Database service, so it would make sense to have a built-in dynamic validation system that can reject bad attempts.All reactions