Base solution for your next web application
Open Closed

How do I implement logout all client with Identity Server 4? #9809


User avatar
0
trungbttsd created

Ver: 9.0.1 Type: MVC Framework: .net core ABP ver: v5.13

Hi support team,

I am in need of handling the full client logout. When any client does the logout, all other clients must also logout. I have reviewed the IS4 documentation here: https://docs.identityserver.io/en/dev/topics/signout.html But I don't know how to use in abpzero yet. So can the support team support me or show me how to use it in abpzero?

Best Regards


2 Answer(s)
  • User Avatar
    0
    gterdem created
    Support Team

    Hello @trungbttsd,

    I think implementing front-channel logout will solve your problem. However it is a bit complicated and tricky at first glance.

    Updating IdentityServer Clients

    You need to update your identityServer clients with the following:

    • Set FrontChannelLogoutUri to $"{webClientRootUrl}Account/FrontChannelLogout". webClientRootUrl will be your client url. We'll implement FrontChannelLogout method in AccountController
    • Set FrontChannelLogoutRequired to true

    Updating AccountController

    • Add FrontChannelLogout method to your AccountController. Sample code is here.
    • Update your Logout method in your AccountController. Sample code is here. You need to get logoutContext using logoutId. LogoutContext has information of PostLogoutRedirectUri and SignOutIFrameUrl. So you can redirect to SignedOut (or LoggedOut) page to display the iframe that will signout of all other clients.

    Add LoggedOut Page

    You need to add a new page to redirect after logging out, to signout from other clients and/or redirect back to your client. You can see sample implementations of our LoggedOut.cshtml and LoggedOut.cshtml.cs.

    I hope this will be helpful.

  • User Avatar
    0
    trungbttsd created

    Solved. Thanks team!