I am trying to get IdentityServer4 working inside a new .NET Core 2.1 app (it works perfectly inside a .NET Core 2.0 app). I have tried the following:
1) Download this project, which is the IdentityServer4 application: https://github.com/ghstahl/IdentityServer4-Asp.Net-2.1-Identity-Examples/tree/e0aeeff7e078aa082c8e16029dd2c220acc77d7b
2) Download this project, which is the MVC application using the Identity Server4 application: https://github.com/IdentityServer/IdentityServer4.Samples/tree/dev/Quickstarts/6_AspNetIdentity/src/MvcClient.
3) Add the two projects to the same solution. The MVC project uses the IdentityServer project for authentication; authorisation etc.
I had to make the following changes:
1) Change to the Startup contained in the IdentityServer app (AddIdentityServer now accepts an argument):
services.AddIdentityServer(options =>
{
options.UserInteraction.LoginUrl = "/Identity/Account/Login";
options.UserInteraction.LogoutUrl = "/Identity/Account/Logout";
})
2) Configure the IdentityServer app to listen on port 5000 and disable SSL on the identity server.
Everything works as expected out of the box, except the logout facility. When I click log out in the MVC application; the following code is called inside the MVC app:
public async Task Logout()
{
await HttpContext.SignOutAsync("Cookies");
await HttpContext.SignOutAsync("oidc");
}
The user is then redirected to Logout.cshtml in the IdentityServer app. However, they have to click log out again (on the IdentityServer app) in order to actually log out i.e. they click log out in the MVC app (point two), then log out in IdentityServer (point one).
Why does the end user have to log out twice?

SignOutAsyncthat does not require the schema parameter. - CleptusHttpContextobject. I refer to this overload That could be called eitherSystem.Threading.Tasks.Task.SignOutAsync(HttpContext);oHttpContext.SignOutAsync();The 1st one calls directly the static method and the 2nd one uses the extension method directly. - CleptusLogoutin your MVC app, you logout of the MVC app but are still logged in with IS4. This is kinda like signing into an app using Google - you're signed in to Google itself and the app that uses Google. When you signed out of said app that uses Google, you don't also sign out of Google itself. - Kirk Larkin