🐛 Bug Report: Realtime does not recognize auth status of Appwrite client instances authenticated with setSession #8925
Labels
api / realtime
Fixes and upgrades for the Appwrite Realtime API.
bug
Something isn't working
product / auth
Fixes and upgrades for the Appwrite Auth / Users / Teams services.
👟 Reproduction steps
When I authenticate a client-side Appwrite instance with
client.setSession(sessionCookie)
, Realtime doesn't recognize the authed status of the instance.I'm doing SSR auth, and one of my API endpoints in Nuxt returns the session cookie to clients that authenticate successfully. Then, I use that cookie to authenticate the client-side Appwrite instance.
Most requests requiring an authed status work (eg: I can use that same client-side Appwrite instance to fetch user-only collections, etc.) Only Realtime doesn't recognize the authed status of the instance.
I am currently developing in localhost only and my Appwrite endpoint is https://cloud.appwrite.io/v1, so I couldn't configure the session cookie to be automatically sent to Appwrite in addition to localhost.
PS: If any additional context is needed, I first reported this in this Discord thread.
👍 Expected behavior
Realtime recognizes the auth status of Appwrite instances authenticated with
client.setSession()
, and streams events that conform to the instance's auth status.This would keep Realtime consistent with all other Appwrite services, which already support instances authenticated with
client.setSession()
, and spare people doing SSR auth the need to reimplement auth client-side, specially when they can't yet configure a custom Appwrite endpoint.👎 Actual Behavior
Realtime's auth detection is inconsistent with the rest of Appwrite.
Both
account.getSession('current')
and accessing a collection where only users have read permission withdatabases.listDocuments()
return the current session and the list of documents, respectively, showing they can detect the auth status of Appwrite instances authenticated withclient.setSession(sessionCookie)
.But, subscribing to Realtime channels that require being authenticated (like being a user to 'read' a collection) with that same Appwrite instance doesn't work, and the Realtime connection does not stream to the authenticated client any of the events in those channels.
🎲 Appwrite version
Appwrite Cloud
💻 Operating system
MacOS
🧱 Your Environment
Tech stack is just Nuxt and Appwrite. No significant environment customizations in place.
"nuxt": "^3.13.2", "node-appwrite": "^14.1.0", "appwrite": "^16.0.2"
I'm doing SSR auth and then returning the session cookie from my API endpoint to the client when authenticated. I then use that cookie to authenticate the client-side Appwrite instance that goes on to establish the Realtime connection.
I'm not really using this client-side client for anything other than Realtime (all requests to data in my Appwrite collections are handled by server-side Appwrite client instances). But, I modified my client-side Appwrite util to return account and databases to test the auth status of my client-side instance.
👀 Have you spent some time to check if this issue has been raised before?
🏢 Have you read the Code of Conduct?
The text was updated successfully, but these errors were encountered: