Skip to content

Conversation

@bobjflong
Copy link
Contributor

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

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
Copy link
Owner

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, added

Copy link
Owner

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

Copy link
Contributor Author

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(..)
Copy link
Owner

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 SameSiteOption type, not its constructors
  • Provide sameSiteLax :: SameSiteOption and sameSiteStrict :: SameSiteOption exports

Copy link
Contributor Author

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
Copy link
Contributor Author

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

@snoyberg snoyberg merged commit daf2c0d into snoyberg:master Apr 20, 2016
@snoyberg
Copy link
Owner

Awesome, merged. I added a small fix to the new NFData instance. Just confirming with Travis and then I'll release to Hackage.

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