Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to encrypt cookies without using a jar? #132

Closed
bbigras opened this issue Dec 18, 2019 · 4 comments · May be fixed by #229
Closed

Is it possible to encrypt cookies without using a jar? #132

bbigras opened this issue Dec 18, 2019 · 4 comments · May be fixed by #229

Comments

@bbigras
Copy link

bbigras commented Dec 18, 2019

I don't think I need to store cookies. I guess the jar is useful to revoke cookies.

In my case I think I would just prefer not storing them and rotate the key from time to time.

Is this possible?

@SergioBenitez
Copy link
Member

This is not possible with the existing API, though it wouldn't be difficult to add this functionality. What do you want to do with the Cookie afterward? Presumably just to_string() it? If so, then we can expose an API similar to that of Cookie::encoded().

@bbigras
Copy link
Author

bbigras commented Jan 24, 2020

Yes I use to_string() to send it to the client.

I also do it in reverse to validate the cookie:

let mut jar = CookieJar::new();
jar.add(Cookie::new("my_session", cookie2));
let cookie = jar.private(&key)
    .get("my_session")
    .map(|c| c.value().to_string());

@SergioBenitez
Copy link
Member

I'd happily accept a PR that adds this functionality in the form of Cookie::encoded().

@SergioBenitez
Copy link
Member

Closing due to inactivity. Still happy to accept a PR.

tp971 added a commit to tp971/cookie-rs that referenced this issue Oct 16, 2024
These methods allow encrypting/decrypting and signing/verifying cookies without
using a `PrivateJar` or `SignedJar`.

Resolves rwf2#132.
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 a pull request may close this issue.

2 participants