public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext) { var identity = filterContext.HttpContext.Request.LogonUserIdentity; bool canExecute = (identity == null ? false : identity.IsAuthenticated); if (!canExecute) filterContext.Result = new HttpUnauthorizedResult(); }
public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext) { var user = filterContext.HttpContext.User; if (user == null || !user.Identity.IsAuthenticated) { filterContext.Result = new HttpUnauthorizedResult(); return; } var identity = user.Identity as ClaimsIdentity; if (identity == null) { filterContext.Result = new HttpUnauthorizedResult(); return; } var profileType = identity.Claims.FirstOrDefault(c => c.Type == SignInService.PROFILE_TYPE_CLAIMS_KEY); if (profileType == null) { filterContext.Result = new HttpUnauthorizedResult(); return; } if (!_profileType.Contains(profileType.Value)) filterContext.Result = profileType.Value == SignInService.PROFILE_TYPE_ADMIN ? new RedirectResult("/Advertiser/Account/Login") : new RedirectResult("/Admin/Account/Login"); }
public override void OnAuthenticationChallenge(System.Web.Mvc.Filters.AuthenticationChallengeContext filterContext) { if (!filterContext.HttpContext.User.Identity.IsAuthenticated) { filterContext.Result = new RedirectResult("/User/Login"); } }
public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext) { filterContext.Result = new BasicChallengeActionResult { CurrrentResult = filterContext.Result }; }
public void OnAuthenticationChallenge(AuthenticationChallengeContext context) { if (context.Result == null || context.Result is HttpUnauthorizedResult) { if (!context.HttpContext.Request.IsAjaxRequest()) { if (_redirectToLogin) { var url = context.RequestContext.HttpContext.Request.Url.AbsolutePath; if (string.IsNullOrEmpty(url) || string.IsNullOrWhiteSpace(url) || url.Equals("/")) { context.Result = new RedirectToRouteResult("login", null); } else { context.Result = new RedirectToRouteResult("login", new System.Web.Routing.RouteValueDictionary{ {"r", HttpUtility.UrlEncode(context.RequestContext.HttpContext.Request.Url.AbsoluteUri) } }); } } else { context.Result = new RedirectToRouteResult("Default", new System.Web.Routing.RouteValueDictionary{ {"controller", "Error"}, {"action", "Error404"} }); } } } }
public void OnAuthenticationChallenge(AuthenticationChallengeContext context) { if (context.Result is HttpUnauthorizedResult) context.Result = new RedirectToRouteResult(new RouteValueDictionary { { "controller", "Auth" }, { "action", "Start" } }); }
public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext) { var user = filterContext.HttpContext.User; if (user == null || !user.Identity.IsAuthenticated) { filterContext.Result = new HttpUnauthorizedResult(); } }
public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext) { if(AuthenticationUtility.IsAuthenticated || AuthenticationUtility.GetAuthorizationMode(filterContext.ActionDescriptor) == AuthorizationMode.Disabled) return; var url = Utility.RepairQueryString(Zongsoft.Web.Security.AuthenticationUtility.GetLoginUrl(), filterContext.HttpContext.Request.Url.Query); url = Utility.RepairQueryString(url, "?ReturnUrl=" + Uri.EscapeDataString(filterContext.HttpContext.Request.RawUrl)); filterContext.Result = new RedirectResult(url); }
public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext) { bool isSession = Convert.ToBoolean(filterContext.HttpContext.Session["user"]); if (!isSession) { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary( new { action = "Index", controller = "TestLogin", area = "Admin" })); } }
public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext) { if (filterContext.Result == null || filterContext.Result is HttpUnauthorizedResult) filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary { {"controller", "Home" }, {"action", "Index" }, {"area", "" } }); }
public void OnAuthenticationChallenge(AuthenticationChallengeContext context) { if (context.Result == null || context.Result is HttpUnauthorizedResult) { context.Result = new RedirectToRouteResult("Default", new System.Web.Routing.RouteValueDictionary { { "Controller", "LoginCP" }, { "Action", "Logout" }, { "returnUrl", context.HttpContext.Request.RawUrl } }); } }
public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext) { var color = ((MyCustomPrincipal)filterContext.HttpContext.User).HairColor; var user = filterContext.HttpContext.User; if (color == "Red" && !user.Identity.IsAuthenticated) { filterContext.Result = new HttpUnauthorizedResult(); } }
public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext) { if (filterContext.Result == null || filterContext.Result is HttpUnauthorizedResult) { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { {"controller", "Employee"}, {"action", "Login"} }); } }
public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext) { var user = filterContext.HttpContext.User; if (user == null || !user.Identity.IsAuthenticated) { filterContext.Result = new RedirectToRouteResult( new System.Web.Routing.RouteValueDictionary { { "controller", "Account" }, { "action", "Login" } }); } }
public override void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext) { var statusCodeResult = filterContext.Result as HttpStatusCodeResult; if (statusCodeResult != null && statusCodeResult.StatusCode == 401) { filterContext.Result = new ViewResult() { ViewName = "AccessDenied" }; } }
public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext) { if (filterContext.Result == null || filterContext.Result is HttpUnauthorizedResult) { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { {"controller", "Client"}, {"action", "Login"}, {"returnUrl", filterContext.HttpContext.Request.RawUrl} }); } }
/// <summary> /// Checks that the user is authenticated. /// </summary> public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext) { BaseAuthorizedController authController = filterContext.Controller as BaseAuthorizedController; if ((authController != null) && (authController.AllowMixedMode)) return; var user = filterContext.HttpContext.User; if (user == null || !user.Identity.IsAuthenticated) { filterContext.Result = new HttpUnauthorizedResult(); } }
public void OnAuthenticationChallenge(AuthenticationChallengeContext context) { if (context.Result == null || context.Result is HttpUnauthorizedResult) { context.Result = new RedirectToRouteResult(new RouteValueDictionary { {"controller", "GoogleAccount"}, {"action", "Login"}, {"returnUrl", context.HttpContext.Request.RawUrl} }); } else { FormsAuthentication.SignOut(); } }
public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext) { // public virtual IPrincipal User { get; set; } // 傳回:包含目前 HTTP 要求之安全性資訊的物件。 var user = filterContext.HttpContext.User; if ((user == null) || (!user.Identity.IsAuthenticated && !user.IsInRole("Admin"))) { // 修改Action Result的結果 filterContext.Result = new HttpUnauthorizedResult(); } }
public void OnAuthenticationChallenge(AuthenticationChallengeContext context) { if (context.Result == null || context.Result is HttpUnauthorizedResult) { context.Result = new RedirectToRouteResult(new RouteValueDictionary { {"controller", "Account"}, {"action", "Login"}, {"area", "Admin"}, {"returnURL", context.HttpContext.Request.RawUrl} }); } }
public override void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext) { var statusCodeResult = filterContext.Result as HttpStatusCodeResult; if (statusCodeResult != null && statusCodeResult.StatusCode == 401) { var ctx = filterContext.HttpContext.Request.GetOwinContext(); var url = ctx.Environment.CreateSignInRequest(new SignInMessage { ReturnUrl = filterContext.HttpContext.Request.Url.AbsoluteUri }); filterContext.Result = new RedirectResult(url); } }
public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext) { if (filterContext.Result is HttpUnauthorizedResult) { filterContext.HttpContext.Response.SuppressFormsAuthenticationRedirect = true; filterContext.Result = new RedirectToRouteResult( new RouteValueDictionary { { "controller", "Account" }, { "action", "AccessDenied" }, { "area", "Orchard.Users"}, { "ReturnUrl", filterContext.HttpContext.Request.RawUrl } }); } }
public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext) { var skipAuthorization = filterContext.ActionDescriptor.IsDefined(typeof(AllowAnonymousAttribute), true) || filterContext.ActionDescriptor.ControllerDescriptor.IsDefined( typeof(AllowAnonymousAttribute), true); if (!skipAuthorization) { var user = filterContext.HttpContext.User; if (user == null || !user.Identity.IsAuthenticated) { filterContext.Result = new HttpUnauthorizedResult(); } } }
public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext) { // Check if this action has NotAuthorizeAttribute object[] attributes = filterContext.ActionDescriptor.GetCustomAttributes(true); if (attributes.Any(a => a is NotAuthorizeAttribute)) { return; } var user = filterContext.HttpContext.User; if (user == null || !user.Identity.IsAuthenticated) { filterContext.Result = new HttpUnauthorizedResult(); } }
public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext) { if (!filterContext.IsChildAction && !filterContext.HttpContext.Request.IsAjaxRequest()) { var statusCodeResult = filterContext.Result as HttpStatusCodeResult; if (statusCodeResult != null && statusCodeResult.StatusCode == 403) { filterContext.Result = new ViewResult() { ViewName = this.viewName }; } } }
public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext) { //if (filterContext.Controller is Controllers.AccountController) return; //var user = filterContext.HttpContext.User; //if (Csla.ApplicationContext.User != null && // Csla.ApplicationContext.User.Identity.IsAuthenticated) //{ // ProjectTracker.Library.Security.PTPrincipal.Load(Csla.ApplicationContext.User.Identity.Name); //} //if (user == null || !user.Identity.IsAuthenticated) //{ // filterContext.Result = new HttpUnauthorizedResult(); //} ProjectTracker.Library.Security.PTPrincipal.Login("manager", "manager"); }
public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext) { // check your roles here // if user cant’s access the resource then set bool skipAuthorization = filterContext.ActionDescriptor.IsDefined( typeof(AllowAnonymousAttribute), inherit: true) || filterContext.ActionDescriptor.ControllerDescriptor.IsDefined( typeof(AllowAnonymousAttribute), inherit: true); if (skipAuthorization) return; if (!HttpContext.Current.User.Identity.IsAuthenticated) { filterContext.Result = new HttpUnauthorizedResult(); } }
public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext) { string challenge; if (String.IsNullOrEmpty(Realm)) { challenge = "Basic"; } else { // A correct implementation should verify that Realm does not contain a quote character unless properly // escaped (precededed by a backslash that is not itself escaped). challenge = "Basic realm=\"" + Realm + "\""; } filterContext.ChallengeWith(challenge); }
void IAuthenticationFilter.OnAuthenticationChallenge(AuthenticationChallengeContext filterContext) { string Name = filterContext.HttpContext.User.Identity.Name; var user = filterContext.HttpContext.User; if (user == null || !user.Identity.IsAuthenticated) { filterContext.Result = new HttpUnauthorizedResult(); } else { string controllerName = filterContext.RouteData.Values["controller"].ToString(); string actionName = filterContext.RouteData.Values["action"].ToString(); // Authentication challenge trace centralyzed Helpers.MyTracer.MyTrace(System.Diagnostics.TraceLevel.Info, this.GetType(), controllerName, actionName, "OnAuthenticationChallenge", null); } }
public virtual void OnAuthenticationChallenge(System.Web.Mvc.Filters.AuthenticationChallengeContext filterContext) { }
public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext) { }
public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext) { filterContext.Result = new LoggingActionResult("From authentication filter challenge"); }