Beispiel #1
0
        public ActionResult SLOService()
        {
            // Receive the single logout request or response.
            // If a request is received then single logout is being initiated by the service provider.
            // If a response is received then this is in response to single logout having been initiated by the identity provider.
            bool   isRequest    = false;
            bool   hasCompleted = false;
            string logoutReason = null;
            string partnerSP    = null;

            SAMLIdentityProvider.ReceiveSLO(Request, Response, out isRequest, out hasCompleted, out logoutReason, out partnerSP);

            if (isRequest)
            {
                // Logout locally.
                FormsAuthentication.SignOut();

                // Respond to the SP-initiated SLO request indicating successful logout.
                SAMLIdentityProvider.SendSLO(Response, null);
            }
            else
            {
                if (hasCompleted)
                {
                    // IdP-initiated SLO has completed.
                    Response.Redirect("~/");
                }
            }

            return(new EmptyResult());
        }
Beispiel #2
0
        public ActionResult SLOService()
        {
            var isRequest    = false;
            var hasCompleted = false;
            var logoutReason = default(string);
            var partnerSP    = default(string);

            SAMLIdentityProvider.ReceiveSLO(
                Request,
                Response,
                out isRequest,
                out hasCompleted,
                out logoutReason,
                out partnerSP);

            // If this is a request, then the logout was initiated by a partner SP.
            if (isRequest)
            {
                Response.ForgetUserIdentity();
                SAMLIdentityProvider.SendSLO(Response, null);
            }
            else if (hasCompleted)
            {
                // IdP-initiated SLO has completed.
                Response.ForgetUserIdentity();
                Response.Redirect("~/");
            }

            return(new EmptyResult());
        }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Receive the single logout request or response.
            // If a request is received then single logout is being initiated by the service provider.
            // If a response is received then this is in response to single logout having been initiated by the identity provider.
            bool   isRequest    = false;
            bool   hasCompleted = false;
            string logoutReason = null;
            string partnerSP    = null;
            string relayState   = null;

            SAMLIdentityProvider.ReceiveSLO(Request, Response, out isRequest, out hasCompleted, out logoutReason, out partnerSP, out relayState);

            if (isRequest)
            {
                // Logout locally.
                FormsAuthentication.SignOut();

                // Respond to the SP-initiated SLO request indicating successful logout.
                SAMLIdentityProvider.SendSLO(Response, null);
            }
            else
            {
                if (hasCompleted)
                {
                    // IdP-initiated SLO has completed.
                    Response.Redirect("~/");
                }
            }
        }
Beispiel #4
0
        public ActionResult SingleLogoutService()
        {
            // Receive the single logout request or response.
            // If a request is received then single logout is being initiated by a partner service provider.
            // If a response is received then this is in response to single logout having been initiated by the identity provider.
            bool   isRequest;
            bool   hasCompleted;
            string logoutReason;
            string partnerName;
            string relayState;

            SAMLIdentityProvider.ReceiveSLO(
                Request,
                Response,
                out isRequest,
                out hasCompleted,
                out logoutReason,
                out partnerName,
                out relayState);

            if (isRequest)
            {
                // Logout locally.
                HttpContext.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie);

                // Respond to the SP-initiated SLO request indicating successful logout.
                SAMLIdentityProvider.SendSLO(Response, null);
            }
            else
            {
                if (hasCompleted)
                {
                    // IdP-initiated SLO has completed.
                    if (!string.IsNullOrEmpty(relayState) && Url.IsLocalUrl(relayState))
                    {
                        return(Redirect(relayState));
                    }

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

            return(new EmptyResult());
        }
Beispiel #5
0
        private static void ReceiveLogoutMessageFromServiceProvider(XmlElement xmlElement)
        {
            SAML.HttpContext = new SAMLHttpContext();
            SAMLHttpRequest  samlHttpRequest  = new SAMLHttpRequest(xmlElement, null, null, null);
            SAMLHttpResponse samlHttpResponse = new SAMLHttpResponse();

            bool   isRequest    = false;
            bool   hasCompleted = false;
            string logoutReason = null;
            string partnerSP    = null;
            string relayState   = null;

            SAMLIdentityProvider.ReceiveSLO(samlHttpRequest, samlHttpResponse, out isRequest, out hasCompleted, out logoutReason, out partnerSP, out relayState);

            Console.WriteLine("Logout request: {0}", isRequest);
            Console.WriteLine("Logout completed: {0}", hasCompleted);
            Console.WriteLine("Logout reason: {0}", logoutReason);
            Console.WriteLine("Partner SP: {0}", partnerSP);
        }
Beispiel #6
0
        public ActionResult SLOService()
        {
            // Receive the single logout request or response.
            // If a request is received then single logout is being initiated by the service provider.
            // If a response is received then this is in response to single logout having been initiated by the identity provider.
            bool   isRequest    = false;
            bool   hasCompleted = false;
            string logoutReason = null;
            string partnerSP    = null;
            string relayState   = null;

            SAMLIdentityProvider.ReceiveSLO(Request, Response, out isRequest, out hasCompleted, out logoutReason, out partnerSP, out relayState);

            if (isRequest)
            {
                // Logout locally.
                FormsAuthentication.SignOut();

                string logoutPath = UtilityMethods.ReadConfigValue("pathLogout");
                _log.Debug("Calling " + logoutPath);
                string logoutResponse = WebServiceRequester.MakeWebPageCall(logoutPath);
                this.HttpContext.CleanupCookies();


                // Respond to the SP-initiated SLO request indicating successful logout.
                SAMLIdentityProvider.SendSLO(Response, null);
            }
            else
            {
                if (hasCompleted)
                {
                    // IdP-initiated SLO has completed.
                    Response.Redirect("~/");
                }
            }

            return(new EmptyResult());
        }
Beispiel #7
0
        public ActionResult IdpSloService()
        {
            bool   isRequest, hasCompleted;
            string logoutReason, partnerSp;

            SAMLIdentityProvider.ReceiveSLO(Request, Response, out isRequest, out hasCompleted, out logoutReason, out partnerSp);

            if (isRequest)
            {
                SessionHelper.Set(SourceDomainSessionKey, null);
                SessionHelper.Set(UserSessionKey, null);

                SAMLIdentityProvider.SendSLO(Response, null);
            }
            else
            {
                if (hasCompleted)
                {
                    Response.Redirect("~/");
                }
            }

            return(new EmptyResult());
        }