flyte: [BUG] Error creating secure cookie, caused by: securecookie: the value is too long
Describe the bug
When I use the AzureAD + OpenID for flyte authentication. The id token is too large to be stored in the cookie store. Thus, it will error out as:
{"json":{"src":"handlers.go:141"},"level":"debug","msg":"Running callback handler... for RequestURI /callback?code=0.AQEAv4j5cvGGr0GRqy180BHbRyHCmSqcLoZDjb392JCAaB8aAAA.AgABAAIAAAD--DLA3VO7QrddgJg7WevrAgDs_wUA9P8pIaLZ0SovwKJIJ5RTq6pg_bfpdtJyfIgzV-efLwbA9NvA7JCYOpdRodROyekph4oHqW3cBQldkYMJ6Fr1x-Qy8VxFRqrIi3bOILsw0YA9tMvvCZ22Dx2C-Olpp0le3ip1xTRwPsBNX7CfblaK58-MAFYlOiWBMaQ32pQLMbge_bokdvEXauWRijMYL2EtetUA-msuwxiHOI8VVWYvOD7QB9Llx2btcZbNjS78pNuhCMFPbFWWsqLHAn6GPsMUFhsW9TGPR193Iv0Jw2HEx-GXSB8yUwJEYlUkikC6JKUyJFkMDTWp_NcxGKQiH3S62E4m1tJol2xY-hEAO03iIUDFThXXJeY8MumjzlQfi4XOcur12CvAoNTqEnooCJ3ShkJ_iaWDDSEup1Gy1b8kEMnSOCY9vKCU2itzocIhAGDdoECB30tn5bBzOqlbi2sUqGE7ObZFBt92GJK8nhXNlk57lWWN3efYA0P4ojO5vbZhTU9ST8a0ImNwrz46AqGJSwF1ECYfPT8mmGG0yb7lObtsYkSaj8aoARDQhR2uwGA3A818Jq3Q-_L0YwhqZfAjDpg6K41JzGekT9x00i8TtNgv1-rLhIa4kCai7TbwRld2IMhhNMpq7TLlwtnM5FBmKFjmX4tMY84SqPfypN3xmMgAtsU6fwVuKJquWPMoZJz-zM-psBLZXvSn7Wf8xRY1EyZd5GliCHwT-ZSdQ5za5iWSeVuqDABZAEiGpvIZ6SDGqa-NIGlG32vJESHNowXZqF094QTTtD6xcs2QcRVC3nOfZzXMnmwrSjr-GcKI1ge9Ze5efRLjIpwI0-yi3GF_AVBONSelcXS-CxmpP5ipHbMR4inzQslCkmYrf57R62zQojRA0JtT-3nAkS_JUvYVnGs\u0026state=3e851cb5ebcde0b9ac7e583beaf02d628dfcebb299d9b899251a7cb83ae4c342\u0026session_state=9420d37f-ae08-448a-b3c2-6c464387ac10","ts":"2023-06-06T17:49:44Z"}
{"json":{"src":"cookie_manager.go:155"},"level":"error","msg":"Error generating encrypted id token cookie [SECURE_COOKIE_ERROR] Error creating secure cookie, caused by: securecookie: the value is too long","ts":"2023-06-06T17:49:45Z"}
{"json":{"src":"handlers.go:162"},"level":"error","msg":"Error setting encrypted JWT cookie [SECURE_COOKIE_ERROR] Error creating secure cookie, caused by: securecookie: the value is too long","ts":"2023-06-06T17:49:45Z"}
User’s authentication will fail.
Expected behavior
User should be able to authenticate.
Additional context to reproduce
No response
Screenshots
No response
Are you sure this issue hasn’t been raised already?
- Yes
Have you read the Code of Conduct?
- Yes
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 10
- Comments: 17 (13 by maintainers)
I am currently doing a fix in our internal fork but would like to see how @wild-endeavor thinks about the solution. Essentially, we are splitting up the access tokens into two and store them in two separate cookies. (flyte_at has the first half, flyte_at_1 has the second half). I can generalize this to handle token of arbitrary length by splitting into small cookies. Do you think that sounds like a valid solution to the community?
hey guys, for this issue, the cause is “github.com/gorilla/securecookie”'s hash function will generate a hashed token that exceeds the limit of 4096 of cookie size limit of browsers, which means the original query string might not exceed the limit but the encoded string does. Our internal solution is: split the hashed the access token into 2 cookies and combine them when fetching. It worked fine for us so we didn’t really investigate on a more formal solution.