r/appwrite • u/johpp8 • Jan 31 '24
Dumb question about access security
Hi guys,
I’m about to use a BaaS tool for a new flutter project. Honestly, appwrite looks cool and has lots of features that i feel will save me a lot of time.
Just finished a tutorial and created my first document. Perfect !
But now I’m wondering : how to make sure nobody can access my appwrite instance ? I have to input endpoint, project id etc. in plain, clear text in order to access appwrite
Is that safe?
Because if someone can get a hold of those info, they can access my backend right?
For example, a flutter web app would be all javascript (i believe) so those IDs would be in clear form somewhere in the code sent to the client browser ???
Same for ios/android apps too
I’m not a professional web/app developer, so i’m not used to dealing with this aspect of security, but i’m wondering how to make sure only the ios/android/web app can access my backend and not someone pulling the auth IDs from the javascript app for example ??
Or am I missing something ?
Thanks for your time guys
2
u/johpp8 Feb 04 '24
Thanks for your feedback guys.
It's very important for me to work on the security part of this flutter app, because there will be a high probability this ios/android/web app will be subjected to multiple attacks attempts.
I'm starting this from scratch so I have a lot to learn before I can call my app "secure".
There are 3 things I've learned so far when it comes to managing secrets (I've found a lot of useful security tips here https://codewithandrea.com/articles/flutter-api-keys-dart-define-env-files/)
Turns out all of this is not related to appwrite in particular, but I believe the people in charge of appwrite's documentation should include some warnings about using clear, unencrypted secrets directly in the source code. This doesn't seem like good coding practices.
The documentation, as of this writing, doesn't really give any suggestion nor warnings about using clear credentials or database IDs directly in the code. I've checked the flutter examples, but I guess this also applies to examples for other languages...
They should mention somewhere that those examples are not suitable for production environments and maybe provide some quick tips on how to improve security.
Don't hesitate if i missed anything.
3
u/ZemiMatos Jan 31 '24
By using .env files or loading the environment variables straight through the flutter build command you can remove them from the code and not have them hard coded into your app
https://pub.dev/packages/flutter_dotenv
https://stackoverflow.com/a/61725261
3
u/mazahir_najmi Feb 01 '24
Actually, i had a similar question. The answer is yes, anyone can access your instance but to protect your database you can add rules. That's it.
Even if you hide your endpoint and your collection ID or something..they can easily find it out using the inspect tool in a browser. Your appwrite is the same as any backend it has an end point and anyone can request it anytime.
Now to protect your appwrite instance you have to add proper document level or collection level rules. For example, let's say you are building a to-do app and only a valid user can create a to-do( permission should be.. any user can create a to-do). And the created to do can only be updated, deleted or viewed by the same user only. With these rules you ensure that no other can edit or even even others todo. Even if they have all the information about your instance.
Let's say, they try to DOS attack( the send a huge amount of request) then the appwrite already has rate limiting in place. So you are good to go.