Web Developer
Currently, in my SvelteKit Web Application, I'm using Appwrite as my DB and Authentication/User management backend. I'm using Discord OAuth with Appwrite to log the user in. Since I'm using OAuth, I can't follow this Appwrite SSR Auth with Svelte: https://github.com/Meldiron/appwrite-svelte-ssr because my server does not see the set-cookies headers, which contain the auth secret. As a result, I've had to come up with a workaround. As seen in the diagram attached, I end up making the client create a JWT which the server can use for SSR (very simplified). There are a few issues with this though:
- The JWT lasts for 15 minutes and then it expires due because of the way Appwrite works (https://appwrite.io/docs/references/cloud/client-web/account#createJWT)
- After 15 minutes, the client will still be logged in since it has the cookies from Appwrite, but the server will not because the JWT will have expired resulting in pretty bad desync
- When using the JWT on the server, there is no session linked (I can't use
#getSession('current');), forcing me to add a Session Id cookie in order to get session info
These issues mean that my app is slower and users are limited to a ~15 minute session (because I don't want desync). In an ideal world, the cookie that Appwrite sets on the client (with the auth secret) would also be available to the server so that it can authenticate with the same thing. I'd like to know if there is a better way to do authentication with Appwrite, SvelteKit, and Discord OAuth. Or, if there is a way to not limit users to a 15 minute session. Also, I am aware of the third-party cookies stuff (https://appwrite.io/docs/advanced/platform/custom-domains#third-party-cookies), but I don't think that the solutions offered there would help in this case.
I may be wrong in some of my assumptions, so please correct me. If you could offer any help, it would be much appreciated!