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

Set the cookie "Secure" flag iff the ACS post back URL is HTTPS #1135

Closed

Conversation

ulrichb
Copy link
Contributor

@ulrichb ulrichb commented Dec 16, 2019

Partially fixes #1091 (for the ASP.NET Core version).

This allows to comply with the new (Chrome >= 80) "Reject insecure SameSite=None cookies" rule (which otherwise would drop the SignInCommand correlation cookie).

Manually tested:

  • ASP.NET Core: Chrome 80 (Dev Channel) with enabled "SameSite by default cookies" and "Cookies without SameSite must be secure" flags in chrome://flags/

@ulrichb
Copy link
Contributor Author

ulrichb commented Dec 16, 2019

@AndersAbel This is a proposal for #1091 (comment).

I use the AssertionConsumerServiceUrl.Scheme because it's exactly the post back URL and also includes the PublicOrigin (if set).

What do you think?

This allows to comply with the new (Chrome >= 80) "Reject insecure SameSite=None cookies" rule (which otherwise would drop the correlation cookie).
@ulrichb ulrichb force-pushed the SecureFlagOnCorrelationCookie branch from 44e6abc to 947ed7e Compare December 16, 2019 11:22
@ulrichb ulrichb changed the title !WIP! Set the cookie "Secure" flag iff the ACS post back URL is HTTPS Set the cookie "Secure" flag iff the ACS post back URL is HTTPS Dec 16, 2019
@ulrichb
Copy link
Contributor Author

ulrichb commented Dec 18, 2019

@AndersAbel Could you take a look at this? Chrome 80 will be released in February ....

@AndersAbel
Copy link
Member

@ulrichb I had a quick look and I think it looks good, but I need to look a bit more in detail on it before merging.

Is this the only change needed for Chrome 80 to work? I assumed that a SameSite value must also be set (except for that old version of Safari that requires agent sniffing to detect)?

@ulrichb
Copy link
Contributor Author

ulrichb commented Dec 18, 2019

Is this the only change needed for Chrome 80 to work?

I successfully tested the login procedure (against an ADFS Server) with Chrome 80 Dev Channel (+ enabled "SameSite by default cookies" and "Cookies without SameSite must be secure" in chrome://flags/).
(Did not test the logout federation.)


I assumed that a SameSite value must also be set

For ASP.NET Core SameSite=None is already set. (See CommandResultExtensions).

For Sustainsys.Saml2.Mvc, a target framework change to 4.7.2 would be necessary to set SameSite = None. See https://docs.microsoft.com/en-us/dotnet/api/system.web.httpcookie.samesite.

For Owin, a library update to 4.1.0 seems to be necessary. See aspnet/AspNetKatana#201.

(I only use the ASP.NET Core version.)

@ulrichb
Copy link
Contributor Author

ulrichb commented Dec 18, 2019

I updated the description above to "Partially fixes #1091 (for the ASP.NET Core version)."

@mklinke
Copy link

mklinke commented Dec 18, 2019

@ulrichb What version of ASP.NET Core have you tested against? Also, won't this break local debugging without HTTPS? At least that's possible with the current implementation. Not sure if the change in Chrome 80 alone will already break that...

@ulrichb
Copy link
Contributor Author

ulrichb commented Dec 18, 2019

ASP.NET Core 2.2. And oh, I forgot to mention that the explicit SameSite=None emitting only happens when you have ASP.NET Core >= 2.1.14 or ASP.NET Core >= 2.2.8, before these patch versions the "None" value was simply ignored (see dotnet/aspnetcore#13746.)


Also, won't this break local debugging without HTTPS?

That's the reason why I used urls.AssertionConsumerServiceUrl.Scheme ... to avoid the secure flag on HTTP hosts (or theoretically PublicOrigin's). But yes, HTTP localhost testing doesn't work in Chrome >= 80 (unless you explicitly disable the flags, which you can do for debugging purposes); but this is a general problem for all non-HTTPS (localhost debugging) cross origin cookies ...

@ulrichb
Copy link
Contributor Author

ulrichb commented Jan 10, 2020

@mklinke Do you need any further info? (February is coming ....)

@mklinke
Copy link

mklinke commented Jan 10, 2020

@ulrichb Not sure, what you're asking. I'm yet another user of the library as of now. My project is currently based on .NET Core 3.0 and I found the issue as a blocker when I tried upgrading to .NET Core 3.1 due to the SameSite breaking change there.

@ulrichb
Copy link
Contributor Author

ulrichb commented Jan 10, 2020

Sorry, I meant @AndersAbel :)

@AndersAbel
Copy link
Member

@ulrichb @mklinke I'm working on the releases for this right now, please see #1091 for status as that's the main issue.

@ulrichb
Copy link
Contributor Author

ulrichb commented Jan 14, 2020

Thanks @AndersAbel !

@AndersAbel
Copy link
Member

Note: Need to apply the Secure flag for the redirect to Discovery Service too, I'll fix that when merging.

@ulrichb
Copy link
Contributor Author

ulrichb commented Jan 14, 2020

Cool. Thx!

@AndersAbel
Copy link
Member

I ended using cherry-pick to integrate this - first to the v1 branch and then to master. So I'm marking this PR as "closed" but it means "merged"

@AndersAbel AndersAbel closed this Jan 16, 2020
@AndersAbel AndersAbel added this to the v2.4.0 milestone Jan 16, 2020
@ulrichb ulrichb deleted the SecureFlagOnCorrelationCookie branch January 18, 2020 10:24
@ulrichb
Copy link
Contributor Author

ulrichb commented Jan 18, 2020

@AndersAbel Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Please support SameSite=None and Secure when setting cookies
3 participants