public static bool TriggerExternalSignout(this LoggedOutInfoDto dto) { if (dto == null) { throw new ArgumentNullException(nameof(dto)); } return(dto.ExternalAuthenticationScheme != null); }
private async Task <LoggedOutInfoDto> BuildLoggedOutInfoDtoAsync(string logoutId) { // get context information (client name, post logout redirect URI and iframe for federated signout) var logout = await this.interaction.GetLogoutContextAsync(logoutId); var dto = new LoggedOutInfoDto { AutomaticRedirectAfterSignOut = AccountOptions.AutomaticRedirectAfterSignOut, PostLogoutRedirectUri = logout?.PostLogoutRedirectUri, ClientName = string.IsNullOrEmpty(logout?.ClientName) ? logout?.ClientId : logout?.ClientName, SignOutIframeUrl = logout?.SignOutIFrameUrl, LogoutId = logoutId }; if (User?.Identity.IsAuthenticated == true) { var idp = User.FindFirst(JwtClaimTypes.IdentityProvider)?.Value; if (idp != null && idp != IdentityServerConstants.LocalIdentityProvider) { var providerSupportsSignout = await HttpContext.GetSchemeSupportsSignOutAsync(idp); if (providerSupportsSignout) { if (dto.LogoutId == null) { // if there's no current logout context, we need to create one // this captures necessary info from the current logged in user // before we signout and redirect away to the external IdP for signout dto.LogoutId = await this.interaction.CreateLogoutContextAsync(); } dto.ExternalAuthenticationScheme = idp; } } } return(dto); }