-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
What's missing?
So: Cookies are strings. Rocket's system for inserting and extracting cookies has you reading and writing explicitly the exact strings that will go in the cookie.
However, add_private/get_private are non-explicit. When I read or write a private cookie, the string is not being written literally but rather encrypted.
I have a cookie I write which is, locally, a 64-bit integer. In order to write it to a cookie, I have to convert it to decimal or base64 or something. But I'm using a private cookie. The private cookie, after it encrypts, logically must be base64ing itself (or something).
Why can't I store arbitrary binary data, such as a 64-bit int, in a private cookie?
Ideal Solution
I'm not actually sure what the most Rusty way to communicate the data to get_cookie is. Vec instead of str I guess? Right now add_private uses Cookie<'a> so it might be necessary to either create a PrivateCookie<'a> which supports a broader range of Froms, or add more capabilities to Cookie<'a>.
Why can't this be implemented outside of Rocket?
It doesn't appear to be possible to use the private cookie encryption except through add_private/get_private.
Are there workarounds usable today?
I don't like my workaround as much (base64 then encrypt) because I think that this will result in a longer final encrypted string than encrypting the underlying bytes. That's not a meaningful issue if my cookie is an int64, but for longer cookies it could be.
Alternative Solutions
No response
Additional Context
Is this maybe actually possible already and I'm just missing how?
System Checks
- I do not believe that this feature can or should be implemented outside of Rocket.
- I was unable to find a previous request for this feature.