Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Update default settings for SameSite #1232

Merged
merged 1 commit into from
May 26, 2017
Merged

Update default settings for SameSite #1232

merged 1 commit into from
May 26, 2017

Conversation

JunTaoLuo
Copy link
Contributor

Addresses #1231 Need to test this with the auth samples before merging.

@dnfclas
Copy link

dnfclas commented May 25, 2017

@JunTaoLuo,
Thanks for having already signed the Contribution License Agreement. Your agreement was validated by .NET Foundation. We will now review your pull request.
Thanks,
.NET Foundation Pull Request Bot

@@ -22,7 +22,7 @@ public CookieAuthenticationOptions()
ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter;
ExpireTimeSpan = TimeSpan.FromDays(14);
SlidingExpiration = true;
CookieSameSite = SameSiteMode.Strict;
CookieSameSite = SameSiteMode.Lax;

Choose a reason for hiding this comment

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

Can you put a comment in indicating why we're using lax? Even just a link to the issue would be sufficient. Just something so that somebody doesn't come along 6 months later and decide to change it :)

Copy link
Member

@Tratcher Tratcher left a comment

Choose a reason for hiding this comment

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

If the OIDC & Social samples work.

@@ -203,7 +203,7 @@ protected virtual void GenerateCorrelationId(AuthenticationProperties properties
var cookieOptions = new CookieOptions
{
HttpOnly = true,
SameSite = SameSiteMode.Lax,
SameSite = SameSiteMode.Strict,
Copy link
Contributor

Choose a reason for hiding this comment

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

Hum, does that really work with the OIDC client when using response_mode=form_post? (in this case, the IdP returns an auto-submit HTML form pointing to the callback URL).

Copy link
Contributor

Choose a reason for hiding this comment

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

BTW, I'm curious, what's the point of using a same-site policy for the correlation/anti-XSRF cookies?

Copy link
Member

Choose a reason for hiding this comment

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

You're right, Strict isn't going to work.

For consistency we're considering setting SameSite for all cookies that can work with it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Consistency is great and should always win, but be careful: RemoteAuthenticationHandler is a very generic base class that can be used to implement custom protocols (I personally wrote an OpenID 2.0 middleware leveraging it). That would be annoying to break scenarios that do fancy things with the callback dance... this same-site thingy tends to be really zealous 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right, Strict isn't going to work.

@Tratcher I'm not sure Lax will work with response_mode=form_post since POST is not considered as a "safe" method by the specification.

@JunTaoLuo did Lax work for you?

@@ -161,7 +161,7 @@ public TwitterHandler(IOptionsSnapshot<TwitterOptions> options, ILoggerFactory l
var cookieOptions = new CookieOptions
{
HttpOnly = true,
SameSite = SameSiteMode.Lax,
SameSite = SameSiteMode.Strict,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same remark as above. Twitter - that implements OAuth1 - uses GET/302 responses to return the user back to the client app. If Strict doesn't work with the final application cookie due to the cross-origin 302 dance - as explained by @anurse - it will likely not work here.

@JunTaoLuo
Copy link
Contributor Author

Tested OIDCSample and OIDC.AzureAdSample. This is ready to merge

@JunTaoLuo JunTaoLuo force-pushed the johluo/samesite-update branch from 4d0a986 to cf99250 Compare May 26, 2017 08:43
- Need Lax policy for social authentication
- Need None policy for OIDC
@JunTaoLuo JunTaoLuo force-pushed the johluo/samesite-update branch from cf99250 to c523839 Compare May 26, 2017 19:19
@JunTaoLuo JunTaoLuo merged commit c523839 into dev May 26, 2017
@JunTaoLuo JunTaoLuo deleted the johluo/samesite-update branch May 26, 2017 21:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants