Rank 3: Container
Okay, as I mentioned earlier, I'm using a proxy server. When a user makes a request to the proxy server and they are authenticated with the external auth system, I'll get their Auth token on the request object and verify it on the server. Appwrite allows setting user permissions regardless of whether the role exists or not. For example, I can set a collection permission like this 'write("user:273")', and appwrite will allow it even if the user with the id of 273 doesn't actually exist in my appwrite's user base. That's what I'm taking advantage of. So, I can just use any user id from an external auth system in my permission definition for any appwrite resource.
When the user makes the request, I verify their token, and get their id, and then, if the user is trying to access a document for example using the GetDocument endpoint, I'll fetch the collection, read it's permission field and see if the user's role is included in the read permissions. If it's there, I proxy the request directly to the user on the client. If not, I check if document security is enabled on the collection, if not, I return a 401, else, I fetch the document and see if it's permissions field includes a read permission for the user. If it does, I return the document, else, I return a 401.
This is just an overview of it, not how I actually plan to implement it.
Btw, I do all the fetches on the proxy server with API key Auth.