/// <summary> Process this object. </summary> /// <remarks> ebrown, 6/10/2011. </remarks> /// <exception cref="ArgumentNullException"> Thrown when the context or configuration are null. </exception> /// <param name="context"> The context. </param> /// <param name="configuration"> The configuration. </param> public static void Process(HttpContextBase context, IHttpAuthenticationConfiguration configuration) { if (null == context) { throw new ArgumentNullException("context"); } if (null == configuration) { throw new ArgumentNullException("configuration"); } // check if module is enabled if (!configuration.Enabled) return; log.InfoFormat(CultureInfo.InvariantCulture, "AuthenticateRequest - processing HTTP headers for authentication information"); var inspectors = configuration.Inspectors .ToDictionary(i => i, i => default(AuthenticationResult)); if (inspectors.Count > 0 && inspectors.All(i => i.Key.Configuration.RequireSsl) && !context.Request.IsSecureConnection) { log.ErrorFormat(CultureInfo.InvariantCulture, "All inspector configurations require SSL, but request is not secure"); context.Response.StatusCode = (int)HttpStatusCode.Forbidden; var application = context.ApplicationInstance; if (null != application) { application.CompleteRequest(); } } //try each of our inspectors in configured order - if one is successful and creates an IPrincipal, return if (AnyInspectorSuccesful(context, inspectors)) return; //since we've dropped down this far, it means we have a problem -- nothing authenticated -- so we look at //our config to determine how to respond to the failure ExecuteFailureHandler(context, inspectors, configuration.FailureHandler); }
/// <summary> Process this object. </summary> /// <remarks> ebrown, 6/10/2011. </remarks> /// <exception cref="ArgumentNullException"> Thrown when the context or configuration are null. </exception> /// <param name="context"> The context. </param> /// <param name="configuration"> The configuration. </param> public static void Process(HttpContextBase context, IHttpAuthenticationConfiguration configuration) { if (null == context) { throw new ArgumentNullException("context"); } if (null == configuration) { throw new ArgumentNullException("configuration"); } // check if module is enabled if (!configuration.Enabled) { return; } log.InfoFormat(CultureInfo.InvariantCulture, "AuthenticateRequest - processing HTTP headers for authentication information"); var inspectors = configuration.Inspectors .ToDictionary(i => i, i => default(AuthenticationResult)); if (inspectors.Count > 0 && inspectors.All(i => i.Key.Configuration.RequireSsl) && !context.Request.IsSecureConnection) { log.ErrorFormat(CultureInfo.InvariantCulture, "All inspector configurations require SSL, but request is not secure"); context.Response.StatusCode = (int)HttpStatusCode.Forbidden; var application = context.ApplicationInstance; if (null != application) { application.CompleteRequest(); } } //try each of our inspectors in configured order - if one is successful and creates an IPrincipal, return if (AnyInspectorSuccesful(context, inspectors)) { return; } //since we've dropped down this far, it means we have a problem -- nothing authenticated -- so we look at //our config to determine how to respond to the failure ExecuteFailureHandler(context, inspectors, configuration.FailureHandler); }