I'm running an ASP.NET MVC (4.7.2) web application. I authenticate externally with an Identity Server 4 instance with the Hybrid flow.
When testing the new "missing SameSite defaults to LAX" feature of Firefox, he doesn't sent the LAX OpenIdConnect.Nonce cookie back to my MVC web application:
Image 1: all cookies have Lax
Image 2: No cookies provided at POST to signin-oidc
I get the error:
OpenIdConnectProtocolValidationContext.Nonce was null, OpenIdConnectProtocol.ValidatedIdToken.Payload.Nonce was not null. The nonce cannot be validated. If you don't need to check the nonce, set OpenIdConnectProtocolValidator.RequireNonce to 'false'. Note if a 'nonce' is found it will be evaluated.
I tried a few things to enfore all cookies to have at least a None or Unspecified setting, but this OpenIdConnect.Nonce cookie keeps sticking at LAX.
app.UseKentorOwinCookieSaver();
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Cookies",
CookieSameSite = SameSiteMode.None,
CookieManager = new SameSiteCookieManager(new SystemWebCookieManager())
});
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
Authority = configDetails.IdentityProviderUrl,
AuthenticationType = "Cookies",
ClientId = configDetails.ClientId,
Scope = configDetails.Scope,
ResponseType = "id_token code",
RedirectUri = !string.IsNullOrWhiteSpace(configDetails.RedirectUri) ? configDetails.RedirectUri : "~/",
SignInAsAuthenticationType = "Cookies",
UseTokenLifetime = false,
Notifications = new OpenIdConnectAuthenticationNotifications
{
AuthorizationCodeReceived = AuthorizationCodeReceived,
RedirectToIdentityProvider = n =>
{
if (n.ProtocolMessage.RequestType != Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectRequestType.Logout) return Task.FromResult(0);
var idTokenHint = n.OwinContext.Authentication.User.FindFirst("id_token");
if (idTokenHint != null)
{
n.ProtocolMessage.IdTokenHint = idTokenHint.Value;
}
return Task.FromResult(0);
}
},
CookieManager = new SameSiteCookieManager(new SystemWebCookieManager()),
});
In my web.config I've added:
<system.web>
<httpCookies sameSite="None" requireSSL="true" />
</system.web>
I'm using the SameSiteCookieManager from Microsoft MSDN.
I hope someone can help me setting this OpenIdConnect.Nonce cookie to None or Unspecified.
Many thanks in advance!