Exemplo n.º 1
0
        public async Task <LoggedOutOutput> ExecuteAsync(string logoutId)
        {
            var getLogoutRequestTask = _logoutService.GetLogoutRequestAsync(logoutId);
            var claimsPrincipal      = _claimsPrincipalService.GetClaimsPrincipal();
            var logoutRequest        = await getLogoutRequestTask;

            if (claimsPrincipal?.Identity != null && claimsPrincipal.Identity.IsAuthenticated)
            {
                var signOutTask = _signOutService.SignOutAsync();

                if (logoutRequest.SubjectId.HasValue)
                {
                    await _persistedGrantRepository.DeleteAllBySubjectIdAsync(logoutRequest.SubjectId.Value);
                }

                var   idp = _claimsPrincipalService.GetNonLocalIdentityProvider(claimsPrincipal);
                await signOutTask;

                if (!string.IsNullOrWhiteSpace(idp) && await _schemeService.SchemeSupportsSignOutAsync(idp))
                {
                    if (string.IsNullOrWhiteSpace(logoutId))
                    {
                        logoutId = await _logoutService.CreateLogoutContextAsync();
                    }

                    return(new LoggedOutOutput(logoutId, logoutRequest.PostLogoutRedirectUri,
                                               logoutRequest.SignOutIFrameUrl, logoutRequest.ClientId, idp));
                }
            }

            return(new LoggedOutOutput(logoutId, logoutRequest?.PostLogoutRedirectUri,
                                       logoutRequest?.SignOutIFrameUrl, logoutRequest?.ClientId, null));
        }
Exemplo n.º 2
0
        public async Task CreateLogoutContextAsync_Should_Create_LogoutContext()
        {
            const string logoutContext = "LogoutContext";

            _identityServerInteractionServiceMock.Setup(x => x.CreateLogoutContextAsync()).ReturnsAsync(logoutContext);

            var result = await _service.CreateLogoutContextAsync();

            result.Should().Be(logoutContext);
        }