Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add multi-part session cookie support to fix long URL issue - #606

#606
Open
bduffany wants to merge 1 commit into
vouch:mastervouch/vouch-proxy:masterfrom
bduffany:multipart-session-cookiebduffany/vouch-proxy:multipart-session-cookieCopy head branch name to clipboard
Open

Add multi-part session cookie support to fix long URL issue#606
bduffany wants to merge 1 commit into
vouch:mastervouch/vouch-proxy:masterfrom
bduffany:multipart-session-cookiebduffany/vouch-proxy:multipart-session-cookieCopy head branch name to clipboard

Conversation

@bduffany

@bduffany bduffany commented Feb 4, 2026

Copy link
Copy Markdown

Related issue: #348

The problem: When a user visits a protected URL that is very long (e.g., a Grafana explore URL with a complex query), the session cookie exceeds the securecookie MaxLength of 4096 bytes, causing a "securecookie: the value is too long" error. This breaks the OAuth flow - the session isn't saved, so when the OAuth callback returns, the state validation fails with "Invalid session state".

The solution: Implement a MultiPartCookieStore that:

  1. Removes the securecookie MaxLength limit (we handle size ourselves)
  2. Automatically splits large session cookies into multiple parts (e.g., VouchSession_1of3, VouchSession_2of3, VouchSession_3of3)
  3. Reassembles the parts when reading the session back

This approach mirrors how Vouch already handles large JWT cookies in pkg/cookie/cookie.go.

The change is backwards compatible - existing session cookies will continue to work because:

  • The store first tries to read a single cookie before looking for parts
  • The same securecookie encoding is used
  • Small sessions are still written as single cookies

@bduffany
bduffany force-pushed the multipart-session-cookie branch 5 times, most recently from 4f36115 to 5b65041 Compare February 4, 2026 14:25
@bduffany
bduffany marked this pull request as ready for review February 4, 2026 14:32
This fixes vouch#348

The problem: When a user visits a protected URL that is very long
(e.g., a Grafana explore URL with a complex query), the session
cookie exceeds the securecookie MaxLength of 4096 bytes, causing
a "securecookie: the value is too long" error. This breaks the
OAuth flow - the session isn't saved, so when the OAuth callback
returns, the state validation fails with "Invalid session state".

The solution: Implement a MultiPartCookieStore that:
1. Removes the securecookie MaxLength limit (we handle size ourselves)
2. Automatically splits large session cookies into multiple parts
   (e.g., VouchSession_1of3, VouchSession_2of3, VouchSession_3of3)
3. Reassembles the parts when reading the session back

This approach mirrors how Vouch already handles large JWT cookies
in pkg/cookie/cookie.go.

The change is backwards compatible - existing session cookies will
continue to work because:
- The store first tries to read a single cookie before looking for parts
- The same securecookie encoding is used
- Small sessions are still written as single cookies

Dockerfile: Updated Go from 1.23 to 1.24, required by dependencies
(golang.org/x/net requires go >= 1.24.0).
@bduffany
bduffany force-pushed the multipart-session-cookie branch from 5b65041 to fcb327e Compare February 10, 2026 02:33
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.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.