Closed 54mu3l closed 11 months ago
The POST binding writes to the body and that causes the headers to be flushed. Signing out of the cookie scheme means that a set-cookie
header is set to clear the cookie.
As you've found out, the order becomes important here. The cookie signout must be done first, to be able to write the headers. After that, the Saml2 signout using POST can run.
There's no need to do the full workaround though, simply reordering the parameters should work:
return SignOut(props, CookieAuthenticationDefaults.AuthenticationScheme, Saml2Defaults.Scheme);
Before I opened this issue we tried reordering the parameters. But without success.
But now it works with the reordered parameters (the reason was another bug). The POST works now with the following line of code:
return SignOut(props, CookieAuthenticationDefaults.AuthenticationScheme, Saml2Defaults.Scheme);
It might be worth mentioning, that the example signs-out saml first and then the cookie: https://github.com/Sustainsys/Saml2.Samples/blob/dcbcc42093e12a988da45782446e538ca33e45eb/v2/AspNetCore/Pages/Logout.cshtml.cs#L20
Mabye the example needs an update.
Good point. I've updated the samples and added a comment on why the order matters. When I wrote the sample, I probably only used HttpRedirect for the logout.
Problem
When we use
HttpPost
asSingleLogoutServiceBinding
we get the following error: The response headers cannot be modified because the response has already started.When we use
HttpRedirect
asSingleLogoutServiceBinding
it works flawlessly.Has anyone seen something similar? Is this a know bug? Or just misconfiguration on our side?
Code
Log
Current workaround
The following code seems to work (for now):
Additional info
Sustainsys.Saml2.AspNetCore2 2.9.0 .NET 7.0