supabase / auth-helpers

A collection of framework specific Auth utilities for working with Supabase.
https://supabase.github.io/auth-helpers/
MIT License
902 stars 237 forks source link

SSR: Chunked cookie is setting wrong if new cookie has less length #715

Closed dvvolynkin closed 8 months ago

dvvolynkin commented 9 months ago

Bug report

Describe the bug

If an old cookie has a length 3 chunks if the new cookie will have length 2 chunks then it will not delete the last third chunk before setting new chunks.

It will break refreshing algo and then remove all cookies because the new full cookie will be invalid after dechunkinizing.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository: Set a cookie that has 3 chunks Then set a cookie that will have 2 chunks. The second cookie will be invalid.

Expected behavior

The second cookie have to be valid.

Screenshots

If applicable, add screenshots to help explain your problem.

Garbage in the end of the second cookie:

image
dvvolynkin commented 9 months ago

setItem in createBrowserClient and createServerClient methods has to remove all old cookie chunks before setting the new chunks

astonfuture commented 8 months ago

Similar issues can occur if the new cookie is chunked while the old cookie is non chunked or vice versa.

kangmingtay commented 8 months ago

@astonfuture closing because it's been fixed in #726