public static string GetRedirectUrl(SignOutMessage message, IDictionary<string, object> env, IdentityServerOptions options)
        {
            var result = new LogoutResult(message, env, options);
            var response = result.Execute();

            return response.Headers.Location.AbsoluteUri;
        }
        public SignOutMessage CreateSignoutMessage(ValidatedEndSessionRequest request)
        {
            var message = new SignOutMessage();
            
            if (request.Client != null)
            {
                message.ClientId = request.Client.ClientId;

                if (request.PostLogOutUri != null)
                {
                    message.ReturnUrl = request.PostLogOutUri;
                }
                else
                {
                    if (request.Client.PostLogoutRedirectUris.Any())
                    {
                        message.ReturnUrl = request.Client.PostLogoutRedirectUris.First();
                    }
                }

                if (request.State.IsPresent())
                {
                    if (message.ReturnUrl.IsPresent())
                    {
                        message.ReturnUrl = message.ReturnUrl.AddQueryString("state=" + request.State);
                    }
                }
            }

            return message;
        }
        public LogoutResult(SignOutMessage message, IDictionary<string, object> env, IdentityServerOptions options)
        {
            if (env == null) throw new ArgumentNullException("env");
            if (options == null) throw new ArgumentNullException("options");

            this.env = env;
            this.options = options;

            this.message = message;
        }
        internal static async Task<string> GetClientName(this IClientStore store, SignOutMessage signOutMessage)
        {
            if (store == null) throw new ArgumentNullException("store");

            if (signOutMessage != null && signOutMessage.ClientId.IsPresent())
            {
                var client = await store.FindClientByIdAsync(signOutMessage.ClientId);
                if (client != null)
                {
                    return client.ClientName;
                }
            }

            return null;
        }
 private async Task<string> GetClientNameFromSignOutMessage(SignOutMessage signOutMessage)
 {
     if (signOutMessage != null)
     {
         var client = await _clientStore.FindClientByIdAsync(signOutMessage.ClientId);
         if (client != null)
         {
             return client.ClientName;
         }
     }
     return null;
 }
 public void LoggedOut_WithSignOutMessage_ContainsClientNameAndRedirectUrlInPage()
 {
     GetLoginPage();
     var c = TestClients.Get().First();
     var msg = new SignOutMessage
     {
         ClientId = c.ClientId,
         ReturnUrl = "http://foo"
     };
     var id = WriteMessageToCookie(msg);
     var resp = PostForm(Url(Constants.RoutePaths.Logout + "?id=" + id), null);
     var model = resp.GetModel<LoggedOutViewModel>();
     model.RedirectUrl.Should().Be(msg.ReturnUrl);
     model.ClientName.Should().Be(c.ClientName);
 }
 public void LogoutPrompt_WithSignOutMessage_ContainsClientNameInPage()
 {
     var c = TestClients.Get().First();
     var msg = new SignOutMessage
     {
         ClientId = c.ClientId,
         ReturnUrl = "http://foo"
     };
     var id = WriteMessageToCookie(msg);
     var resp = Get(Constants.RoutePaths.Logout + "?id=" + id);
     var model = resp.GetModel<LogoutViewModel>();
     model.ClientName.Should().Be(c.ClientName);
 }