-
Notifications
You must be signed in to change notification settings - Fork 15
Adds setCookieSameSite security option.
#13
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
Conversation
SameSite is an interesting cookie option that asserts that a cookie should not be included in cross-origin requests. This commit adds a sum type `SameSiteOption` and a function `setCookieSameSite` for interacting with this option. Here is the draft: https://tools.ietf.org/html/draft-west-first-party-cookies-07
Web/Cookie.hs
Outdated
| rnf g `seq` | ||
| rnf h | ||
| rnf h `seq` | ||
| rnfMBS i |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't look correct. Why not define a NFData instance for SameSiteOption and then use rnf?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, my comment was to then replace rnfMBS i with rnf i
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep done in 3c246d4
Web/Cookie.hs
Outdated
| , setCookieHttpOnly | ||
| , setCookieSecure | ||
| , setCookieSameSite | ||
| , SameSiteOption(..) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you aren't opposed, I'd rather switch to smart constructors in case additional SameSiteOption values become valid in the future. I can make that tweak myself if you're OK with it, or you can. What I would picture is:
- Only expose the
SameSiteOptiontype, not its constructors - Provide
sameSiteLax :: SameSiteOptionandsameSiteStrict :: SameSiteOptionexports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds good to me. Added in 4ca5673
Web/Cookie.hs
Outdated
| , setCookieHttpOnly = isJust $ lookup "httponly" flags | ||
| , setCookieSecure = isJust $ lookup "secure" flags | ||
| , setCookieSameSite = case lookup "samesite" flags of | ||
| Just "Lax" -> Just Lax |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just noticed the indentation here is a little off, fixing
|
Awesome, merged. I added a small fix to the new |
SameSite is an interesting cookie option that asserts that a cookie
should not be included in cross-origin requests. This commit adds a sum
type
SameSiteOptionand a functionsetCookieSameSitefor interactingwith this option.
Here is the draft: https://tools.ietf.org/html/draft-west-first-party-cookies-07