supabase / auth-helpers

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

feat(ssr): base64-encode cookie value #701

Closed jebibot closed 5 months ago

jebibot commented 7 months ago

What kind of change does this PR introduce?

Feature

What is the current behavior?

The session cookie value is a plain JSON string, which gets URL-encoded by most server implementations. This causes a mismatch in the length calculation in the chunker; sometimes, cookie values exceed the max length.

What is the new behavior?

This PR base64-encodes the cookie value before passing to the chunker.

The rationale for using base64:

Additional context

Closes #680. Fixes #643 and fixes #696.

dalkommatt commented 6 months ago

I'd love to test this on my own project but was having trouble patching the @supabase/ssr package with this. Is there a way it can be done?

j4w8n commented 6 months ago

If this is considered, it likely needs to use jose for cross-platform support. This has been an issue in the past.

See https://github.com/supabase/auth-helpers/pull/515

dvvolynkin commented 6 months ago

Will it work with unicode symbols in JSON?

It can be user name for example

kangmingtay commented 5 months ago

@dalkommatt i typically do pnpm build in the root of the auth-helpers repo and then npx install-from /path/to/auth-helpers/packages/ssr in the project that i want to test the changes in

@jebibot we've decided to go with #726 to fix the cookie chunking issues so i'll be closing this PR.