IdentityServer4 icon indicating copy to clipboard operation
IdentityServer4 copied to clipboard

How to implement the full logout?

Open atpyk opened this issue 9 years ago • 8 comments

I have the Idsvr4 and MVCClient web portals, and base on OpenId to login and logout. When I login on the MVCClient and then refresh the Idsvr4 that stay on the login page, Idsvr4 will redirect to the internal page; When I logout from the MVCClient, and then refresh the Idsvr4 that stay on the internal page, Idsvr4 will redirect to the login page. So far all things work fine.

But there is another case that cannot logout successfully:

  1. I login on MVCClient, and refresh Idsvr4 that stay on the login page, Idsvr4 will redirect to internal page;
  2. Switch to the Idsvr4 internal page, and logout on it;
  3. Switch to the MVCClient that stay on internal page, and refresh.

Expect: The MVCClient should redirect to the login page automatically. Actual: The MVCClient still stay on the internal page.

Is there any way to implement the full logout? Do some configurations or else? Thanks for your feedback.

atpyk avatar Feb 16 '17 06:02 atpyk

Did you configure the LogoutUrl for the MVC client?

brockallen avatar Feb 16 '17 17:02 brockallen

Yes, I did the config is below:

RedirectUris = { "http://localhost:5003/signin-oidc" }, PostLogoutRedirectUris = { "http://localhost:5003/signout-callback-oidc" },

atpyk avatar Feb 17 '17 01:02 atpyk

you can reproduce the process by my steps, I use the demo your provided.

atpyk avatar Feb 17 '17 01:02 atpyk

You might get better support if you supply us with a repo / sample code. that reproduces this.

Lutando avatar Feb 21 '17 12:02 Lutando

ClientMVC:

app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme, });

        JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();

        app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
        {
            AuthenticationScheme = "oidc",
            SignInScheme = "Cookies",

            Authority = "http://localhost:5000",
            RequireHttpsMetadata = false,

            ClientId = "mvc",
            SaveTokens = true
        });

public class Program { public static void Main(string[] args) { Console.Title = "MVCClient";

        var host = new WebHostBuilder()
            .UseKestrel()
            .UseUrls("http://localhost:5003")
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseIISIntegration()
            .UseStartup<Startup>()
            .Build();

        host.Run();
    }
}

Idsrv4:

public class Config { public static IEnumerable GetIdentityResources() { return new List { new IdentityResources.OpenId(), new IdentityResources.Profile(), }; }

    public static IEnumerable<ApiResource> GetApiResources()
    {
        return new List<ApiResource>
        {
            new ApiResource("api1", "My API")
        };
    }

    public static IEnumerable<Client> GetClients()
    {
        return new List<Client>
        {
         new Client
            {
                ClientId = "mvc",
                ClientName = "MVC Client",
                AllowedGrantTypes = GrantTypes.Implicit,
                 RequireConsent = false,
                // where to redirect to after login
                RedirectUris = { "http://localhost:5003/signin-oidc" },

                // where to redirect to after logout
                PostLogoutRedirectUris = { "http://localhost:5003/signout-callback-oidc" },

                AllowedScopes = new List<string>
                {
                    IdentityServerConstants.StandardScopes.OpenId,
                    IdentityServerConstants.StandardScopes.Profile
                }
            }
        };
    }

    public static List<TestUser> GetUsers()
    {
        return new List<TestUser>
        {
            new TestUser
            {
                SubjectId = "1",
                Username = "alice",
                Password = "password"
            },
            new TestUser
            {
                SubjectId = "2",
                Username = "bob",
                Password = "password"
            }
        };
    }
}

atpyk avatar Feb 24 '17 03:02 atpyk

Yes, I did the config is below: RedirectUris = { "http://localhost:5003/signin-oidc" }, PostLogoutRedirectUris = { "http://localhost:5003/signout-callback-oidc" },

None of those is the LogoutUrl.

brockallen avatar Feb 24 '17 16:02 brockallen

Great. Many thanks.

atpyk avatar Feb 27 '17 07:02 atpyk

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jan 15 '20 01:01 lock[bot]