Ejemplo n.º 1
0
        public ActionResult LogOff()
        {
            SamlPocTraceListener.Log("SAML", $"SamlController.Logout: Request for SLO received.");

            string partnerIdP = ((ClaimsIdentity)User.Identity).FindFirstValue(IdentityProviderClaimType);

            // Logout locally.
            SamlPocTraceListener.Log("SAML", $"SamlController.Logout: Log out user {User.Identity.Name} locally.");
            AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);

            if (SAMLServiceProvider.CanSLO(partnerIdP))
            {
                SamlPocTraceListener.Log("SAML", $"SamlController.Logout: Initiating SLO with IdP {partnerIdP}.");

                // Request logout at the identity provider.
                SAMLServiceProvider.InitiateSLO(Response, null, null, partnerIdP);

                return(new EmptyResult());
            }

            SamlPocTraceListener.Log("SAML", $"SamlController.Logout: Identity Provider {partnerIdP} doesn't support SLO.");

            return(RedirectToAction("Index", "Home"));
        }