Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #649: Use CookieAuthStorageAdapter to allow cookie parsing/serialization for SupabaseClient for @supabase/ssr #650

Closed
wants to merge 4 commits into from

Conversation

prabhpreet
Copy link

@prabhpreet prabhpreet commented Oct 12, 2023

What kind of change does this PR introduce?

Bug - fixes #649
Use CookieAuthStorageAdapter to allow cookie parsing/serialization for SupabaseClient when using @supabase/ssr

This incorporates #609 by @csenio to allow async getCookie methods for the StorageAdapter and get method for ServerCookieMethods in createServerClient in the

What is the current behavior?

Issue described in #649

What is the new behavior?

Creates a storage adapter ServerCookieAuthStorageAdapter in packages/ssr/src/createServerClient.ts by extending CookieAuthStorageAdapter which provides the cookie parsing/serialization expected by SupabaseClient's storage adapter.

@silentworks
Copy link
Contributor

Hi @prabhpreet this is intentional by design to not include the CookieAuthStorageAdapter. We will document how to use this library as we get ready for its official release. At the moment you will need to handle the cookie parsing yourself in your framework's code.

@prabhpreet
Copy link
Author

@silentworks May I ask the reasoning behind avoiding CookieAuthStorageAdapter?

Currently the set method for setting your own Cookies in ServerCookieMethods receives the entire stringified Session type for auth-token cookies, which can be a lot to store and cannot be serialised and stored as Cookies as-is.

Can using CookieAuthStorageAdapter be provided as another option to ServerCookieMethods? Reason being, auth-helpers/shared is parsing of auth-token cookies is separate from code-verifier and I didn't want to reinvent the wheel when using another framework.

Another option can be to provide a typed Session as a value for set and get methods.

@silentworks
Copy link
Contributor

We don't want to handle the overhead of how storage is handled inside this library itself since gotrue-js essentially already does that. We initially did this in the @supabase/auth-helpers because of cookie size limit, we wanted to reduce the size as much as possible when it comes to storing data into a cookie, however this required a number of workarounds which caused more issues than the ideal solution it was trying to provide. Once we have documented @supabase/ssr it will be more clear why we think this is a better approach.

@prabhpreet
Copy link
Author

Thanks, closing PR wrt above comment.

@prabhpreet prabhpreet closed this Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@supabase/ssr does not have cookie parsing/serialization from CookieAuthStorageAdapter
3 participants