diff --git a/backend/src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs b/backend/src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs index 676a27b95..3a62627b9 100644 --- a/backend/src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs +++ b/backend/src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs @@ -13,6 +13,9 @@ using System.Security; using System.Security.Claims; using System.Text; using System.Threading.Tasks; +using IdentityModel; +using IdentityServer4; +using IdentityServer4.Extensions; using IdentityServer4.Models; using IdentityServer4.Services; using Microsoft.AspNetCore.Identity; @@ -145,10 +148,25 @@ namespace Squidex.Areas.IdentityServer.Controllers.Account [Route("account/logout/")] public async Task Logout(string logoutId) { - var context = await interactions.GetLogoutContextAsync(logoutId); - await signInManager.SignOutAsync(); + if (User?.Identity.IsAuthenticated == true) + { + var provider = User.FindFirst(JwtClaimTypes.IdentityProvider)?.Value; + + if (provider != null && provider != IdentityServerConstants.LocalIdentityProvider) + { + var providerSupportsSignout = await HttpContext.GetSchemeSupportsSignOutAsync(provider); + + if (providerSupportsSignout) + { + return SignOut(provider); + } + } + } + + var context = await interactions.GetLogoutContextAsync(logoutId); + return RedirectToLogoutUrl(context); }