示例#1
0
        public string Signout()
        {
            // Load Identity Configuration
            FederationConfiguration config = FederatedAuthentication.FederationConfiguration;

            // Get wtrealm from WsFederationConfiguation Section
            string wtrealm = config.WsFederationConfiguration.Realm;
            string wreply;

            // Construct wreply value from wtrealm
            if (wtrealm.Last().Equals('/'))
            {
                wreply = wtrealm + "";
            }
            else
            {
                wreply = wtrealm + "/";
            }

            // Read the ACS Ws-Federation endpoint from web.Config
            string wsFederationEndpoint = ConfigurationManager.AppSettings["ida:Issuer"];

            SignOutRequestMessage signoutRequestMessage = new SignOutRequestMessage(new Uri(wsFederationEndpoint));

            signoutRequestMessage.Parameters.Add("wreply", wreply);
            signoutRequestMessage.Parameters.Add("wtrealm", wtrealm);

            FederatedAuthentication.SessionAuthenticationModule.SignOut();

            return(signoutRequestMessage.WriteQueryString());
        }
        public ActionResult Signout()
        {
            if (User.Identity.IsAuthenticated)
            {
                FederatedAuthentication.WSFederationAuthenticationModule.SignOut(false);

                string issuer  = FederatedAuthentication.WSFederationAuthenticationModule.Issuer;
                var    signOut = new SignOutRequestMessage(new Uri(issuer));

                // In the Windows Azure environment, build a wreply parameter for  the SignIn request
                // that reflects the real address of the application.
                var request    = this.Request;
                Uri requestUrl = request.Url;

                StringBuilder wreply = new StringBuilder();
                wreply.Append(requestUrl.Scheme);     // e.g. "http" or "https"
                wreply.Append("://");
                wreply.Append(request.Headers["Host"] ?? requestUrl.Authority);
                wreply.Append(request.ApplicationPath);

                if (!request.ApplicationPath.EndsWith("/"))
                {
                    wreply.Append("/");
                }

                signOut.Reply = wreply.ToString();

                return(this.Redirect(signOut.WriteQueryString()));
            }

            return(this.RedirectToAction("Index", "OnBoarding"));
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Load Identity Configuration
            FederationConfiguration config = FederatedAuthentication.FederationConfiguration;

            // Get wtrealm from WsFederationConfiguation Section
            string wtrealm = config.WsFederationConfiguration.Realm;
            string wreply;

            // Construct wreply value from wtrealm
            if (wtrealm.Last().Equals('/'))
            {
                wreply = wtrealm + "default.aspx";
            }
            else
            {
                wreply = wtrealm + "/default.aspx";
            }

            // Read the ACS Ws-Federation endpoint from web.Config
            string wsFederationEndpoint = ConfigurationManager.AppSettings["ida:Issuer"];

            SignOutRequestMessage signoutRequestMessage = new SignOutRequestMessage(new Uri(wsFederationEndpoint));

            signoutRequestMessage.Parameters.Add("wreply", wreply);
            signoutRequestMessage.Parameters.Add("wtrealm", wtrealm);

            FederatedAuthentication.SessionAuthenticationModule.SignOut();

            Response.Redirect(signoutRequestMessage.WriteQueryString());
        }
示例#4
0
        public ActionResult SignOut()
        {
            FederatedAuthentication.WSFederationAuthenticationModule.SignOut(false);

            var signOutRequest = new SignOutRequestMessage(new Uri(FederatedAuthentication.WSFederationAuthenticationModule.Issuer), FederatedAuthentication.WSFederationAuthenticationModule.Realm);
            return new RedirectResult(signOutRequest.WriteQueryString());
        }
        public ActionResult Signout()
        {
            if (User.Identity.IsAuthenticated)
            {
                FederatedAuthentication.WSFederationAuthenticationModule.SignOut(false);

                string issuer = FederatedAuthentication.WSFederationAuthenticationModule.Issuer;
                var signOut = new SignOutRequestMessage(new Uri(issuer));

                // In the Windows Azure environment, build a wreply parameter for  the SignIn request
                // that reflects the real address of the application.
                var request = this.Request;
                Uri requestUrl = request.Url;

                StringBuilder wreply = new StringBuilder();
                wreply.Append(requestUrl.Scheme);     // e.g. "http" or "https"
                wreply.Append("://");
                wreply.Append(request.Headers["Host"] ?? requestUrl.Authority);
                wreply.Append(request.ApplicationPath);

                if (!request.ApplicationPath.EndsWith("/"))
                {
                    wreply.Append("/");
                }

                signOut.Reply = wreply.ToString();

                return this.Redirect(signOut.WriteQueryString());
            }

            return this.RedirectToAction("Index", "OnBoarding");
        }
示例#6
0
 public ActionResult Logout()
 {
     var authModule = FederatedAuthentication.WSFederationAuthenticationModule;
     authModule.SignOut(false);
     var signOutRequestMessage = new SignOutRequestMessage(new Uri(authModule.Issuer), authModule.Realm); // initiate federated sign out request to the STS
     var redirectUrl = signOutRequestMessage.WriteQueryString();
     return Redirect(redirectUrl);
 }
示例#7
0
        public string SignOut()
        {
            var module = FederatedAuthentication.WSFederationAuthenticationModule;
            module.SignOut();
            var signOutRequestMessage = new SignOutRequestMessage(new Uri(module.Issuer), module.Realm);

            return string.Format("{0}&wtrealm={1}", signOutRequestMessage.WriteQueryString(), WebUtility.UrlEncode(module.Realm));
        }
示例#8
0
 public ActionResult SignOut(string returnUrl)
 {
     var fam = FederatedAuthentication.WSFederationAuthenticationModule;
     fam.SignOut(false);
     FormsAuthentication.SignOut();
     Debug.Assert(Request.Url != null, "Request.Url != null");
     var signOutRequestMessage = new SignOutRequestMessage(new Uri(fam.Issuer), returnUrl);
     var parameters = HmacHelper.CreateHmacRequestParametersFromConfig(Consts.PermissionHmacSettingsPrefix);
     parameters.ForEach(signOutRequestMessage.Parameters.Add);
     return new RedirectResult(signOutRequestMessage.WriteQueryString());
 }
        public ActionResult Index()
        {
            var config = FederatedAuthentication.FederationConfiguration.WsFederationConfiguration;

            var callbackUrl = Url.Action("Callback", "Logout", null, Request.Url.Scheme);
            var signoutMessage = new SignOutRequestMessage(new Uri(config.Issuer), callbackUrl);
            signoutMessage.SetParameter("wtrealm", config.Realm);
            FederatedAuthentication.SessionAuthenticationModule.SignOut();

            return new RedirectResult(signoutMessage.WriteQueryString());
        }
        public ActionResult SignOut()
        {
            var config = FederatedAuthentication.FederationConfiguration.WsFederationConfiguration;

            string callbackUrl = Url.Action("Index", "Home", routeValues: null, protocol: Request.Url.Scheme);
            var signoutMessage = new SignOutRequestMessage(new Uri(config.Issuer),callbackUrl);
            signoutMessage.SetParameter("wtrealm",config.Realm);

            FederatedAuthentication.WSFederationAuthenticationModule.SignOut();

            return new RedirectResult(signoutMessage.WriteQueryString());
        }
示例#11
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.IsAuthenticated)
     {
         WsFederationConfiguration config = FederatedAuthentication.FederationConfiguration.WsFederationConfiguration;
         string callbackUrl = Request.Url.GetLeftPart(UriPartial.Authority) + Response.ApplyAppPathModifier("~/");
         SignOutRequestMessage signoutMessage = new SignOutRequestMessage(new Uri(config.Issuer), callbackUrl);
         signoutMessage.SetParameter("wtrealm", IdentityConfig.Realm ?? config.Realm);
         FederatedAuthentication.SessionAuthenticationModule.SignOut();
         Response.Redirect(signoutMessage.WriteQueryString());
     }
 }
        public ActionResult SignOut()
        {
            WsFederationConfiguration config = FederatedAuthentication.FederationConfiguration.WsFederationConfiguration;

            // Redirect to SignOutCallback after signing out.
            string callbackUrl = Url.Action("SignOutCallback", "Account", routeValues: null, protocol: Request.Url.Scheme);
            SignOutRequestMessage signoutMessage = new SignOutRequestMessage(new Uri(config.Issuer), callbackUrl);
            signoutMessage.SetParameter("wtrealm", IdentityConfig.Realm ?? config.Realm);
            FederatedAuthentication.SessionAuthenticationModule.SignOut();

            return new RedirectResult(signoutMessage.WriteQueryString());
        }
示例#13
0
        public ActionResult SignOut()
        {
            WsFederationConfiguration config = FederatedAuthentication.FederationConfiguration.WsFederationConfiguration;

            // Redirect to home page after signing out.
            string callbackUrl = Url.Action("Index", "Home", routeValues: null, protocol: Request.Url.Scheme);
            SignOutRequestMessage signoutMessage = new SignOutRequestMessage(new Uri(config.Issuer), callbackUrl);
            signoutMessage.SetParameter("wtrealm", IdentityConfig.Realm ?? config.Realm);
            FederatedAuthentication.SessionAuthenticationModule.SignOut();

            return new RedirectResult(signoutMessage.WriteQueryString());
        }
示例#14
0
        public ActionResult Index()
        {
            var config = FederatedAuthentication.FederationConfiguration.WsFederationConfiguration;

            var callbackUrl    = Url.Action("Callback", "Logout", null, Request.Url.Scheme);
            var signoutMessage = new SignOutRequestMessage(new Uri(config.Issuer), callbackUrl);

            signoutMessage.SetParameter("wtrealm", config.Realm);
            FederatedAuthentication.SessionAuthenticationModule.SignOut();

            return(new RedirectResult(signoutMessage.WriteQueryString()));
        }
示例#15
0
        //
        // GET: /Admin/SignOut

        public void SignOut()
        {
            WsFederationConfiguration fc = FederatedAuthentication.FederationConfiguration.WsFederationConfiguration;

            string wreply = System.Web.HttpContext.Current.Request.UrlReferrer.ToString();

            SignOutRequestMessage soMessage = new SignOutRequestMessage(new Uri(fc.Issuer), wreply);

            soMessage.SetParameter("wtrealm", fc.Realm);

            FederatedAuthentication.SessionAuthenticationModule.SignOut();
            Response.Redirect(soMessage.WriteQueryString());
        }
        public ActionResult Logout()
        {
            if (this.User.Identity.IsAuthenticated)
            {
                FederatedAuthentication.WSFederationAuthenticationModule.SignOut(false);

                string issuer  = FederatedAuthentication.WSFederationAuthenticationModule.Issuer;
                var    signOut = new SignOutRequestMessage(new Uri(issuer));
                return(this.Redirect(signOut.WriteQueryString()));
            }

            return(this.RedirectToAction("JoinNow"));
        }
示例#17
0
        public ActionResult LogOff()
        {
            WSFederationAuthenticationModule authModule = FederatedAuthentication.WSFederationAuthenticationModule;

            //clear local cookie
            authModule.SignOut(false);

            //initiate federated sign out request to the STS
            SignOutRequestMessage signOutRequestMessage = new SignOutRequestMessage(new Uri(authModule.Issuer), authModule.Realm);
            String queryString = signOutRequestMessage.WriteQueryString();

            return(new RedirectResult(queryString));
        }
        public ActionResult LogOff()
        {
            WSFederationAuthenticationModule authModule = FederatedAuthentication.WSFederationAuthenticationModule;

            //clear local cookie
            authModule.SignOut(false);

            //initiate federated sign out request to the STS
            SignOutRequestMessage signOutRequestMessage = new SignOutRequestMessage(new Uri(authModule.Issuer), authModule.Realm);
            String queryString = signOutRequestMessage.WriteQueryString();
            return new RedirectResult(queryString);

        }
示例#19
0
        public ActionResult LogOff()
        {
            WsFederationConfiguration fc =
            FederatedAuthentication.FederationConfiguration.WsFederationConfiguration;

            string request = System.Web.HttpContext.Current.Request.Url.ToString();
            string wreply = request.Substring(0, request.Length - 7);
            SignOutRequestMessage soMessage =
                            new SignOutRequestMessage(new Uri(fc.Issuer), wreply);
            soMessage.SetParameter("wtrealm", fc.Realm);
            FederatedAuthentication.SessionAuthenticationModule.SignOut();
            Response.Redirect(soMessage.WriteQueryString());
            return RedirectToAction("Index", "Home");
        }
        public ActionResult Signout()
        {
            var fam = FederatedAuthentication.WSFederationAuthenticationModule;

            // clear local cookie
            fam.SignOut(false);

            // initiate a federated sign out request to the sts.
            var signOutRequest = new SignOutRequestMessage(new Uri(fam.Issuer), fam.Realm);

            signOutRequest.Reply = fam.Reply;

            return(new RedirectResult(signOutRequest.WriteQueryString()));
        }
示例#21
0
        public ActionResult LogOff()
        {
            if (this.User.Identity.IsAuthenticated)
            {
                FederatedAuthentication.WSFederationAuthenticationModule.SignOut(false);

                string issuer  = FederatedAuthentication.WSFederationAuthenticationModule.Issuer;
                var    signOut = new SignOutRequestMessage(new Uri(issuer));
                return(new RedirectResult(signOut.WriteQueryString()));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
        public ActionResult LogOff()
        {
            if (this.User.Identity.IsAuthenticated)
            {
                FederatedAuthentication.WSFederationAuthenticationModule.SignOut(false);

                string issuer = FederatedAuthentication.WSFederationAuthenticationModule.Issuer;
                var signOut = new SignOutRequestMessage(new Uri(issuer));
                return new RedirectResult(signOut.WriteQueryString());
            }
            else
            {
                return RedirectToAction("Index", "Home");
            }
        }
示例#23
0
        public ActionResult LogOff()
        {
            var authModule = FederatedAuthentication.WSFederationAuthenticationModule;

            //clear local cookie
            authModule.SignOut(false);

            //initiate federated sign out request to the STS
            var signOutRequestMessage = new SignOutRequestMessage(new Uri(authModule.Issuer), authModule.Realm);
            var queryString           = signOutRequestMessage.WriteQueryString();

            return(new RedirectResult(queryString));

            AuthenticationManager.SignOut();
            return(RedirectToAction("Index", "Home"));
        }
示例#24
0
        public JsonResult Logout()
        {
            // use the WS Federation module to sign-out from the current session and to base the Issuer signout request
            var federationAuth = FederatedAuthentication.WSFederationAuthenticationModule;

            federationAuth.SignOut(false);

            // generate a WS-Federation Sign-Out Url for the IDP that issued the Claims
            var signOutRequest = new SignOutRequestMessage(new Uri(federationAuth.Issuer), federationAuth.Realm)
            {
                Reply = federationAuth.Realm
            };
            var signOutUrl = signOutRequest.WriteQueryString();

            return(Json(signOutUrl, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Logout()
        {
            if (Request.IsAuthenticated)
            {
                // Remove the application cookies, etc.
                WSFederationAuthenticationModule WsFam = FederatedAuthentication.WSFederationAuthenticationModule;
                WsFam.SignOut(false);

                // Issue a sign out request to remove the STS session, etc.  This will cause an SSOut.
                SignOutRequestMessage signOutRequestMessage = new SignOutRequestMessage(new Uri(WsFam.Issuer), WsFam.Reply);
                String signOutRequest = signOutRequestMessage.WriteQueryString() + "&wtrealm=" + WsFam.Realm;
                return(new RedirectResult(signOutRequest));
            }

            return(new RedirectResult("/"));
        }
示例#26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (User.Identity.IsAuthenticated)
            {
                // Remove the application cookies, etc.
                WSFederationAuthenticationModule WsFam = FederatedAuthentication.WSFederationAuthenticationModule;
                WsFam.SignOut(false);

                // Issue a sign out request to remove the STS session, etc.  This will trigger an SSOut.
                SignOutRequestMessage signOutRequestMessage = new SignOutRequestMessage(new Uri(WsFam.Issuer), WsFam.Reply);
                String signOutRequest = signOutRequestMessage.WriteQueryString() + "&wtrealm=" + WsFam.Realm;
                Response.Redirect(signOutRequest);
                return;
            }

            Response.Redirect("/");
        }
        public string GetLogoutUrl()
        {
            // Load Identity Configuration
            FederationConfiguration config = FederatedAuthentication.FederationConfiguration;

            // Get wtrealm from WsFederationConfiguation Section
            string wtrealm = config.WsFederationConfiguration.Realm;
            string wsFederationEndpoint = ConfigurationManager.AppSettings["ida:Issuer"];

            SignOutRequestMessage signoutRequestMessage = new SignOutRequestMessage(new Uri(wsFederationEndpoint), wtrealm);

            signoutRequestMessage.Parameters.Add("wtrealm", wtrealm);
            FederatedAuthentication.SessionAuthenticationModule.SignOut();

            string signoutUrl = signoutRequestMessage.WriteQueryString();

            return(signoutUrl);
        }
示例#28
0
        private ActionResult ProcessWSFedSignOutRequest(SignOutRequestMessage message)
        {
            var idp = GetIdpCookie();

            if (string.IsNullOrWhiteSpace(idp))
            {
                return(ShowSignOutPage(message.Reply));
            }

            var signOutMessage = new SignOutRequestMessage(new Uri(idp));

            if (!string.IsNullOrWhiteSpace(message.Reply))
            {
                signOutMessage.Reply = message.Reply;
            }

            return(Redirect(signOutMessage.WriteQueryString()));
        }
示例#29
0
        private ActionResult ProcessWSFedSignOutRequest(SignOutRequestMessage message)
        {
            var idp = GetIdpCookie();

            if (string.IsNullOrWhiteSpace(idp))
            {
                return(ShowSignOutPage(message.Reply));
            }

            var signOutMessage = new SignOutRequestMessage(new Uri(idp));

            if (!string.IsNullOrWhiteSpace(message.Reply) && IsValidReplyTo(message.Reply))
            {
                var bytes = Encoding.UTF8.GetBytes(message.Reply);
                bytes = MachineKey.Protect(bytes);
                var param = Url.Encode(Convert.ToBase64String(bytes));

                var host = ConfigurationRepository.Global.PublicHostName;
                if (string.IsNullOrWhiteSpace(host))
                {
                    host = Request.Headers["host"];
                }

                var builder = new UriBuilder();
                builder.Host   = host;
                builder.Scheme = Uri.UriSchemeHttps;
                if (ConfigurationRepository.Global.HttpsPort != 443)
                {
                    builder.Port = ConfigurationRepository.Global.HttpsPort;
                }
                builder.Path = Request.ApplicationPath;
                if (!builder.Path.EndsWith("/"))
                {
                    builder.Path += "/";
                }
                builder.Path        += Endpoints.Paths.WSFedHRDSignoutRedirect;
                builder.Query        = "rp=" + param;
                signOutMessage.Reply = builder.ToString();
            }

            return(Redirect(signOutMessage.WriteQueryString()));
        }
        protected override Task HandleSignOutAsync(SignOutContext signOutContext)
        {
            //do the default cookie sign out to kill the apps local cookie.
            var result = base.HandleSignOutAsync(signOutContext);

            //create the Fed Sign Out url from a SignOutRequestMessage
            var    logOutPath         = Options.LogoutPath.HasValue ? Options.LogoutPath : new PathString("/");
            string replyUrl           = $"{Request.Scheme}://{Request.Host}{logOutPath}";
            SignOutRequestMessage req = new SignOutRequestMessage(new Uri(Options.IdPEndpoint));

            req.Parameters.Add("wtrealm", Options.Realm);
            req.Parameters.Add("wreply", replyUrl);
            var signOutUrl = req.WriteQueryString();

            //Add a header to the response containing the fed sign out url. Did this as Redirecting from here in the pipeline doesn't seem to work.
            //Bit of a Hack - this header can be read later if a Fed Sign Out is required.
            Response.Headers.Add("fedSignOutUrl", "https://localhost/IdentityServer/core/wsfed/?wa=wsignout1.0&wtrealm=https%3a%2f%2flocalhost%3a44346%2f&wreply=https%3a%2f%2flocalhost%3a44346%2f");

            return(result);
        }
        public RedirectResult Get()
        {
            //from config in prod
            const string DefaultViewInRp = "User/Get";

            var federationAuthenticationModule = FederatedAuthentication.WSFederationAuthenticationModule;
            federationAuthenticationModule.SignOut(false); //not initiated by sts so false...

            var signOutRequest = new SignOutRequestMessage(new Uri(InfrastructureConstants.StsSignoutUrl))
                                     {
                                         Reply =
                                             Request.UrlReferrer != null
                                                 ? Request.UrlReferrer
                                                       .AbsoluteUri
                                                 : federationAuthenticationModule
                                                       .Realm + DefaultViewInRp
            };

            return new RedirectResult(signOutRequest.WriteQueryString());
        }
示例#32
0
        public RedirectResult Get()
        {
            //from config in prod

            const string DefaultViewInRp = "User/Get";

            var federationAuthenticationModule = FederatedAuthentication.WSFederationAuthenticationModule;
            federationAuthenticationModule.SignOut(false); //not initiated by sts so false...

            var signOutRequest = new SignOutRequestMessage(new Uri("http://sidekick.local/sso/signout"))
                                     {
                                         Reply =
                                             this.Request.UrlReferrer != null
                                                 ? this.Request.UrlReferrer
                                                       .AbsoluteUri
                                                 : federationAuthenticationModule
                                                       .Realm + DefaultViewInRp
            };

            return new RedirectResult(signOutRequest.WriteQueryString());
        }
        protected void Application_Error(object sender, EventArgs e)
        {
            var exception = Server.GetLastError();

            if (exception is CryptographicException)
            {
                var federationAuthenticationModule = FederatedAuthentication.WSFederationAuthenticationModule ?? new WSFederationAuthenticationModule();

                federationAuthenticationModule.SignOut(false);

                var message = WSFederationMessage.CreateFromUri(System.Web.HttpContext.Current.Request.Url);

                // sign in
                var signinMessage = message as SignInRequestMessage;
                if (signinMessage != null)
                {
                    var signoutMessage = new SignOutRequestMessage(new Uri(signinMessage.RequestUrl),
                                                                   signinMessage.Realm);
                    System.Web.HttpContext.Current.Response.Redirect(signoutMessage.WriteQueryString());
                }
            }
        }
示例#34
0
        public RedirectResult Get()
        {
            //from config in prod

            const string DefaultViewInRp = "User/Get";

            var federationAuthenticationModule = FederatedAuthentication.WSFederationAuthenticationModule;

            federationAuthenticationModule.SignOut(false); //not initiated by sts so false...

            var signOutRequest = new SignOutRequestMessage(new Uri("http://sidekick.local/sso/signout"))
            {
                Reply =
                    this.Request.UrlReferrer != null
                                                 ? this.Request.UrlReferrer
                    .AbsoluteUri
                                                 : federationAuthenticationModule
                    .Realm + DefaultViewInRp
            };

            return(new RedirectResult(signOutRequest.WriteQueryString()));
        }
        public ActionResult Logout()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(View("Index"));
            }

            FederatedAuthentication.WSFederationAuthenticationModule.SignOut(false);

            var signOut = new SignOutRequestMessage(new Uri(FederatedAuthentication.WSFederationAuthenticationModule.Issuer), FederatedAuthentication.WSFederationAuthenticationModule.Realm);

            if (Request.Cookies.Get("UserDateTime") != null)
            {
                Response.Cookies.Set(new HttpCookie("UserDateTime")
                {
                    Expires = DateTime.Now.AddDays(-1)
                });
            }

            UserService.Session.Abandon();

            return(Redirect(signOut.WriteQueryString()));
        }
        public ActionResult Signout()
        {
            var fam = FederatedAuthentication.WSFederationAuthenticationModule;

            // clear local cookie
            fam.SignOut(false);

            // initiate a federated sign out request to the sts.
            var signOutRequest = new SignOutRequestMessage(new Uri(fam.Issuer), fam.Realm);
            signOutRequest.Reply = fam.Reply;

            return new RedirectResult(signOutRequest.WriteQueryString());
        }
        public ActionResult LogOff()
        {
            if (this.AuthenticationManager.User.Identity.AuthenticationType == "Federation")
            {
                WsFederationConfiguration config = FederatedAuthentication.FederationConfiguration.WsFederationConfiguration;

                // Redirect to home page after signing out.
                string callbackUrl = Url.Action("Index", "Home", routeValues: null, protocol: Request.Url.Scheme);
                SignOutRequestMessage signoutMessage = new SignOutRequestMessage(new Uri(config.Issuer), callbackUrl);
                signoutMessage.SetParameter("wtrealm", IdentityConfig.Realm ?? config.Realm);
                FederatedAuthentication.SessionAuthenticationModule.SignOut();

                return new RedirectResult(signoutMessage.WriteQueryString());
            }
            else 
            {
                this.AuthenticationManager.SignOut();
                return this.RedirectToAction("Index", "Home");
            }
        }
示例#38
0
 public void Logout()
 {
     Uri requestUrl = HttpContext.Request.Url;  FederationConfiguration config = FederatedAuthentication.FederationConfiguration;  string wtrealm = config.WsFederationConfiguration.Realm; var wreply = new StringBuilder();  wreply.Append(requestUrl.Scheme); wreply.Append("://");  String host = requestUrl.Host; host = host.Replace("127.0.0.1", "localhost"); host = host.Replace("127.0.0.2", "localhost"); wreply.Append(host);  if(! wreply.ToString().EndsWith("/")) wreply.Append("/"); string wsFederationEndpoint = ConfigurationManager.AppSettings["ida:Issuer"];  SignOutRequestMessage signoutRequestMessage = new SignOutRequestMessage(new Uri(wsFederationEndpoint));  signoutRequestMessage.Parameters.Add("wreply", wreply.ToString()); signoutRequestMessage.Parameters.Add("wtrealm", wreply.ToString());  FederatedAuthentication.SessionAuthenticationModule.SignOut();  Response.Redirect(signoutRequestMessage.WriteQueryString());
 }
        private ActionResult ProcessWSFedSignOutRequest(SignOutRequestMessage message)
        {
            var idp = GetIdpCookie();
            if (string.IsNullOrWhiteSpace(idp))
            {
                return ShowSignOutPage(message.Reply);
            }

            var signOutMessage = new SignOutRequestMessage(new Uri(idp));
            if (!string.IsNullOrWhiteSpace(message.Reply) && IsValidReplyTo(message.Reply))
            {
                var bytes = System.Text.Encoding.UTF8.GetBytes(message.Reply);
                bytes = System.Web.Security.MachineKey.Protect(bytes);
                var param = Url.Encode(Convert.ToBase64String(bytes));

                var host = this.ConfigurationRepository.Global.PublicHostName;
                if (String.IsNullOrWhiteSpace(host))
                {
                    host = Request.Headers["host"];
                }

                var builder = new UriBuilder();
                builder.Host = host;
                builder.Scheme = Uri.UriSchemeHttps;
                if (this.ConfigurationRepository.Global.HttpsPort != 443)
                {
                    builder.Port = this.ConfigurationRepository.Global.HttpsPort;
                }
                builder.Path = Request.ApplicationPath;
                if (!builder.Path.EndsWith("/")) builder.Path += "/";
                builder.Path += Thinktecture.IdentityServer.Endpoints.Paths.WSFedHRDSignoutRedirect;
                builder.Query = "rp=" + param;
                signOutMessage.Reply = builder.ToString();
            }

            return Redirect(signOutMessage.WriteQueryString());
        }
示例#40
0
 [Authorize] //[AllowAnonymous]
 public void Logout()
 {
     Uri requestUrl = HttpContext.Request.Url;  FederationConfiguration config = FederatedAuthentication.FederationConfiguration;  string wtrealm = config.WsFederationConfiguration.Realm; var wreply = new StringBuilder();  wreply.Append(requestUrl.Scheme); wreply.Append("://");  String host = requestUrl.Host; host = host.Replace("127.0.0.1", "localhost"); host = host.Replace("127.0.0.2", "localhost"); wreply.Append(host);  if (!wreply.ToString().EndsWith("/"))
     {
         wreply.Append("/");
     }
     string wsFederationEndpoint = ConfigurationManager.AppSettings["ida:Issuer"];  SignOutRequestMessage signoutRequestMessage = new SignOutRequestMessage(new Uri(wsFederationEndpoint));  signoutRequestMessage.Parameters.Add("wreply", wreply.ToString()); signoutRequestMessage.Parameters.Add("wtrealm", wreply.ToString());  FederatedAuthentication.SessionAuthenticationModule.SignOut();  Response.Redirect(signoutRequestMessage.WriteQueryString());
 }
示例#41
0
 public ActionResult LogOut()
 {
     //WebSecurity.Logout();
     var fam = FederatedAuthentication.WSFederationAuthenticationModule;
     fam.SignOut(false);
     var signOutRequest = new SignOutRequestMessage(new Uri(fam.Issuer), fam.Realm);
     return new RedirectResult(signOutRequest.WriteQueryString());
     //return RedirectToAction("Index", "Home");
 }
示例#42
0
 public ActionResult Logoff()
 {
     WsFederationConfiguration config = FederatedAuthentication.FederationConfiguration.WsFederationConfiguration;
     string callbackUrl = Request.Url.GetLeftPart(UriPartial.Authority) + Response.ApplyAppPathModifier("~/");
     SignOutRequestMessage signoutMessage = new SignOutRequestMessage(new Uri(config.Issuer), callbackUrl);
     signoutMessage.SetParameter("wtrealm", IdentityConfig.Realm ?? config.Realm);
     FederatedAuthentication.SessionAuthenticationModule.SignOut();
     Response.Redirect(signoutMessage.WriteQueryString());
     return null;
 }
        private ActionResult ProcessWSFedSignOutRequest(SignOutRequestMessage message)
        {
            var idp = GetIdpCookie();
            if (string.IsNullOrWhiteSpace(idp))
            {
                return ShowSignOutPage(message.Reply);
            }

            var signOutMessage = new SignOutRequestMessage(new Uri(idp));
            if (!string.IsNullOrWhiteSpace(message.Reply))
            {
                signOutMessage.Reply = message.Reply;
            }

            return Redirect(signOutMessage.WriteQueryString());
        }