Exemple #1
0
        public static void Enable(IPipelines pipelines, IPLockConfiguration configuration)
        {
            if (pipelines == null)
            {
                throw new ArgumentNullException("pipelines");
            }

            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            pipelines.BeforeRequest.AddItemToStartOfPipeline(GetIPCheckHook(configuration));
        }
Exemple #2
0
 private static Func <NancyContext, Response> GetIPCheckHook(IPLockConfiguration configuration)
 {
     return(context => !configuration.IPValidator.IsValid(context.Request.UserHostAddress)
         ? (Response)HttpStatusCode.Forbidden
         : null);
 }