Ejemplo n.º 1
0
        /// <summary>
        /// Redirects the current request back to the requested page without
        /// the CAS ticket artifact in the URL.
        /// </summary>
        public RedirectResult RedirectFromLoginCallback(HttpContextBase httpContext, ActionResult result)
        {
            HttpRequestBase request = httpContext.Request;

            if (_requestEvaluator.GetRequestHasGatewayParameter(httpContext))
            {
                // TODO: Only set Success if request is authenticated?  Otherwise Failure.
                // Doesn't make a difference from a security perspective, but may be clearer for users
                SetGatewayStatusCookie(httpContext, GatewayStatus.Success);
            }

            return(new RedirectResult(_urlUtil.RemoveCasArtifactsFromUrl(request.Url.PathAndQuery)));
        }
Ejemplo n.º 2
0
        public ActionResult OnActionExecuted(WorkContext workContext)
        {
            var httpContext = workContext.HttpContext;

            if (_requestEvaluator.GetRequestRequiresGateway(httpContext, _casClient.GetGatewayStatus(httpContext)))
            {
                Logger.Information("  Performing Gateway Authentication");
                return(_casClient.GatewayAuthenticate(httpContext, true));
            }
            if (_requestEvaluator.GetUserDoesNotAllowSessionCookies(httpContext, _casClient.GetGatewayStatus(httpContext)))
            {
                Logger.Information("  Cookies not supported.  Redirecting to Cookies Required Page");
                return(_casClient.RedirectToCookiesRequiredPage());
            }
            if (_requestEvaluator.GetRequestHasCasTicket(httpContext))
            {
                Logger.Information("  Redirecting from login callback");
                //redirectRequest = _casClient.RedirectFromLoginCallback(context, filterContext.Result);
            }
            else if (_requestEvaluator.GetRequestHasGatewayParameter(httpContext))
            {
                Logger.Information("  Redirecting from failed gateway callback");
                return(_casClient.RedirectFromFailedGatewayCallback(httpContext));
            }
            else if (_requestEvaluator.GetRequestIsUnauthorized(httpContext) &&
                     !String.IsNullOrEmpty(_casServices.Settings.NotAuthorizedUrl))
            {
                Logger.Information("  Redirecting to Unauthorized Page");
                return(_casClient.RedirectToNotAuthorizedPage());
            }
            else if (_requestEvaluator.GetRequestIsUnauthorized(httpContext))
            {
                Logger.Information("  Redirecting to CAS Login Page (Unauthorized without NotAuthorizedUrl defined)");
                return(_casClient.RedirectToLoginPage(true));
            }
            else if (_requestEvaluator.GetRequestIsUnAuthenticated(httpContext))
            {
                Logger.Information("  Redirecting to CAS Login Page");
                return(_casClient.RedirectToLoginPage());
            }

            return(null);
        }