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 Secure and SameSite parameters as options to cookie method #847

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

dadadavorin
Copy link
Contributor

Description

We started getting errors from BugSnag for unsecured cookies, so I solved this on a project, but consider we should also have this as an option in FE Libs cookie helper.

This will set sameSite default to Lax (which is already default, but not in all browsers, like Safari or Firefox). Means that cookie is not sent on cross-site requests by default. More here.

Also, set Secure attribute by default, which indicates that the cookie is sent to the server only when a request is made with the https: scheme (except on localhost), and therefore, is more resistant to man-in-the-middle attacks.

@dadadavorin dadadavorin self-assigned this Jan 28, 2025
@dadadavorin dadadavorin requested a review from a team January 28, 2025 12:04
Comment on lines 41 to 47
const cookieParts = [
`${key}=${value}`,
`expires=${expires.toUTCString()}`,
`SameSite=${sameSite}`,
pathValue,
domainValue,
];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rewrite this so it's an object instead of array of strings

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.

2 participants