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

Add cookie attributes in Web.Session.set #566

Open
Favo02 opened this issue Apr 15, 2024 · 2 comments
Open

Add cookie attributes in Web.Session.set #566

Favo02 opened this issue Apr 15, 2024 · 2 comments

Comments

@Favo02
Copy link

Favo02 commented Apr 15, 2024

Hello, thanks for the incredibly useful library!

I am developing a REST API, the authorization is managed using signed cookies with the Web.Sessions module.

The set cookie function accepts as optional parameters only ?cookie_key and ?secret.
I noticed that the underlying Opium.Response.add_cookie_or_replace offers a bigger API, with ?⁠expires, ?⁠same_site, ?⁠secure and ?⁠http_only parameters, which are all very useful (and important for security reasons) while building apps that uses cookies. Is there any particular reason for "hiding" them?

I ended up using directly Opium.Response.add_cookie_or_replace to set cookies and Web.Sessions.find to read them, which is inconvenient. I think that a few more optional parameters to the Web.Sessions.set function (which would be passed directly to the Opium call) would be really helpful, if needed I can create a PR.

@joseferben
Copy link
Contributor

hey @Favo02!

exposing those parameters would make sense! the main reason that we haven't done that yet, is that the defaults worked for our uses cases. if you want to give it a shot, we'd appreciate a pr!

@Favo02
Copy link
Author

Favo02 commented Apr 17, 2024

The PR needs to wait a bit because the function Opium.Response.add_cookie_or_replace seems to not work with same_site attribute. I opened an issue (opium issue #290) and waiting an answer, I keep this issue updated.

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

No branches or pull requests

2 participants