Logging out of an OpenIDConnect AspNetCore using id_token

The main problem is that I could not find the correct way to exit identityServer4.

Detailed explanation:

The startup.cs client web application contains the following code

app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationScheme = "Cookies",
            AutomaticAuthenticate = true
        });
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
        {
            AuthenticationScheme = "oidc",
            SignInScheme = "Cookies",
            Authority = "http://localhost:1941/",//local identityServer4
            ClientId = "testsoft",
            ClientSecret = "secret",
            ResponseType = "code id_token token",
            GetClaimsFromUserInfoEndpoint = true,
            RequireHttpsMetadata = false,
            Scope = { "openid", "profile", "email" },
            TokenValidationParameters = new TokenValidationParameters()
            {
                NameClaimType = "name",
                RoleClaimType = "role"
            },
            AutomaticAuthenticate = false,
           AutomaticChallenge = true
    });

IdentityServer4, launched locally, is added by the client below:

 new Client
            {
                ClientId = "testsoft",
                ClientName = "testsoft",
                ClientSecrets = new List<Secret>
                {
                    new Secret("secret".Sha256())
                },
                ClientUri = "http://localhost:55383/",//clientside web application url
                AllowedGrantTypes = GrantTypes.Hybrid,
                AllowAccessTokensViaBrowser = true,
                RedirectUris = new List<string>
                {
                    "http://localhost:55383/signin-oidc"
                },
                RequireConsent = false,
                AllowedScopes = new List<string>
                {
                    StandardScopes.OpenId.Name,
                    StandardScopes.Profile.Name,
                    StandardScopes.Email.Name,
                    StandardScopes.Roles.Name,
                    StandardScopes.OfflineAccess.Name,

                    "api1", "api2",
                },
            },

I managed to enter and display Controller-View requests in MVC, as shown

 [Authorize]
    public IActionResult About()
    {
        return View((User as ClaimsPrincipal).Claims);
    }

And the displayed view was like that. Please note that there is no id_token

And the displayed view is as follows.  Please note that id_tokenmissing>

And I managed to exit the cookie as below

 public async Task<IActionResult> LogOut()
    {

        await HttpContext.Authentication.SignOutAsync("Cookies");
        return Redirect("~/");
    }

But the problem is that I can’t find a way to exit IdentityServer. The closer I came, the better it was to use /connect/endsession?id_token_hint=...&post_logout_redirect_uri=https://myapp.com

raw id_token . About(), , (, , id_token), id_token. - id_token url http://localhost:55383/signin-oidc, identServer ( URL ).

:

  • id_token ? ( )
  • ? AspnetCore/Oidc (, , api )?
  • , id_token . : Bob, Alice id_token. Cookie , , , id_token . id_token /?
  • URL- , id_token. , IdentityServer4 id_token?
+4
1

-

HttpContext.Authentication.SignOutAsync("oidc");

" "?

0

All Articles