signin-oidc is pending when authorize is finished [ubuntu16.04]
Everything work fine on my local(windows platform). When I deploy them onto linux(ubuntu16.04), the issue raised.

I can't get any response after I sign in successfully, it always loading until receive a blank page.
What's the status code and headers for that 'blank page'? If it's a 500 then you should check your server logs for an error.
Snapshot1: It takes too long time that is about 15mins.

Snapshot2:

It's my configuration for OpenId middle ware:
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
{
AuthenticationScheme = "oidc",
SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme,
AutomaticAuthenticate = false,
Authority = Settings["AuthorityUrl"],
RequireHttpsMetadata = false,
ClientId = "*****.dashboard",
ClientSecret = "secret",
ResponseType = OpenIdConnectResponseType.CodeIdToken,
Scope = { "basicinfo **** ***" },
GetClaimsFromUserInfoEndpoint = true,
SaveTokens = true,
Events = new OpenIdConnectEvents()
{
OnMessageReceived = context =>
{
if (context.ProtocolMessage.Error != null)
{
context.SkipToNextMiddleware();
context.Response.Redirect("/Home/Error");
}
return Task.FromResult(0);
},
OnRemoteFailure = context =>
{
if (context.Failure is OpenIdConnectProtocolException)
{
context.Response.Redirect("/Home/AccessDenied");
context.HandleResponse();
return Task.FromResult(0);
}
else
{
context.SkipToNextMiddleware();
context.Response.Redirect("/Home/Error");
}
throw context.Failure;
}
}
});
Likely unrelated, but
context.SkipToNextMiddleware();
context.Response.Redirect("/Home/Error");
is a nonsensical combination. You should use HandleResponse() with Redirect.
Also, don't re-throw the exception in OnRemoteFailure.
I forget to remove "OnMessageReceived" section, thanks for your mention.
The issue still have.
@atpyk we recommend enabling logging so that it'll be easier to see at what point the server is taking too long. If you could do that and share your logs we can investigate further.
I report this issue to IdentityServer4 too: 730
No error log in Idsvr side, the client portal side's log is:
fail: Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectMiddleware[17]
Exception occurred while processing message.
Microsoft.IdentityModel.Tokens.SecurityTokenExpiredException: IDX10223: Lifetime validation failed. The token is expired.
ValidTo: '01/22/2017 01:00:59'
Current time: '01/22/2017 01:05:59'.
at Microsoft.IdentityModel.Tokens.Validators.ValidateLifetime(Nullable1 notBefore, Nullable1 expires, SecurityToken securityToken, TokenValidationParameters validationParameters)
at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateLifetime(Nullable1 notBefore, Nullable1 expires, JwtSecurityToken securityToken, TokenValidationParameters validationParameters)
at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateTokenPayload(JwtSecurityToken jwt, TokenValidationParameters validationParameters)
at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateToken(String token, TokenValidationParameters validationParameters, SecurityToken& validatedToken)
at Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.ValidateToken(String idToken, AuthenticationProperties properties, TokenValidationParameters validationParameters, JwtSecurityToken& jwt)
at Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.d__20.MoveNext()
info: Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectMiddleware[4]
Error from RemoteAuthentication: IDX10223: Lifetime validation failed. The token is expired.
ValidTo: '01/22/2017 01:00:59'
Current time: '01/22/2017 01:05:59'..
ValidTo: '01/22/2017 01:00:59' Current time: '01/22/2017 01:05:59'
I'm really tempted to say that @leastprivilege already gave you the right answer: https://github.com/IdentityServer/IdentityServer4/issues/730#issuecomment-274463452.
That said, you likely have another issue (with your proxy?), as the request is not supposed to hang when it's rejected by the OIDC middleware.
We use nginx to deploy the Idsvr4 and webportal on the same sever, and just to do the easy setting for mapping to the corresponding ports, Idsvr4 is 5000; webportal is 5005. Did you guys reproduce this issue by nginx. That's a very tough issue.
@atpyk can you try changing the OnRemoteFailure handler to check for an additional exception type?
Currently it checks context.Failure is OpenIdConnectProtocolException, but in this case you might want to also handle a Microsoft.IdentityModel.Tokens.SecurityTokenExpiredException.
Also, please check the else class of the OnRemoteFailure where it currently has these two lines:
context.SkipToNextMiddleware();
context.Response.Redirect("/Home/Error");
And you probably want to remove the call to context.SkipToNextMiddleware();.
Guys, I found the root cause, so far it took our lots of time. So tough.
We use the .net core 1.1 to develop and deploy the Idsvr4 and Webportal, all the version of packages are >= 1.1.0.
Eventually we had to downgrade these 2 packages to 1.0.1, it has been fixed:
"Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.1.0",
"Microsoft.AspNetCore.Authentication.Cookies": "1.1.0",
"Microsoft.AspNetCore.Diagnostics": "1.1.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Mvc.Formatters.Json": "1.1.0",
"Microsoft.AspNetCore.Routing": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.AspNetCore.StaticFiles": "1.1.0",
Many thanks for @Eilon and @PinpointTownes and @Tratcher 's help. :)
@atpyk ah, yes, mixing versions like that is not supported, so that could definitely be the cause of weird behavior.
Given that this issue appears to be resolved, I'm closing it. Thanks!
Let me clarify it. Not mixed versions lead to this issue; this issue will happen when use the same version(1.1.0) for all packages. The above solution that is the way to work around.
@Eilon it looks like @atpyk means that mixing version does resolve this issue. This can't be the correct solution, can it?
Certainly not, but it does hint that the actual problem is in one of the packages you downgraded.
@cesarbs
@Eilon it looks like @atpyk means that mixing version does resolve this issue. This can't be the correct solution, can it?
Oops, I missed that. This is definitely bizarre.