private bool Authenticate(AuthorizationContext filterContext) { Log.DebugFormat("Authenticate(); ActionContext: {0}", filterContext); /*HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName]; * if (authCookie != null) * { * FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value); * UserIdentity identity = new UserIdentity(ticket.Name); * UserPrincipal principal = new UserPrincipal(identity); * HttpContext.Current.User = principal; * }*/ return(TwitchAuthorization.TryAuth()); /*if (RequireSsl && !HttpContext.Current.Request.IsSecureConnection && !HttpContext.Current.Request.IsLocal) * { * Log.Error("Failed to login: SSL:" + HttpContext.Current.Request.IsSecureConnection); * return false; * } * * if (!HttpContext.Current.Request.Headers.AllKeys.Contains("Authorization")) return false; * * string authHeader = HttpContext.Current.Request.Headers["Authorization"]; * * IPrincipal principal; * if (TryGetPrincipal(authHeader, out principal)) * { * HttpContext.Current.User = principal; * return true; * } * return false;*/ }
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext) { TwitchAuthorization.RedirectToTwitch(); //base.HandleUnauthorizedRequest(filterContext); }