コード例 #1
0
 /// <summary>Enables forms authentication for the application</summary>
 /// <param name="pipelines">Pipelines to add handlers to (usually "this")</param>
 /// <param name="configuration">Forms authentication configuration</param>
 public static void Enable(IPipelines pipelines, CustomAuthenticationConfiguration configuration)
 {
     if (pipelines == null)
     {
         throw new ArgumentNullException("pipelines");
     }
     if (configuration == null)
     {
         throw new ArgumentNullException("configuration");
     }
     if (!configuration.IsValid)
     {
         throw new ArgumentException("Configuration is invalid", "configuration");
     }
     CustomAuthenticationProvider.currentConfiguration = configuration;
     pipelines.BeforeRequest.AddItemToStartOfPipeline(CustomAuthenticationProvider.GetLoadAuthenticationHook(configuration));
     if (configuration.DisableRedirect)
     {
         return;
     }
     pipelines.AfterRequest.AddItemToEndOfPipeline(CustomAuthenticationProvider.GetRedirectToLoginHook(configuration));
 }
コード例 #2
0
 /// <summary>Enables forms authentication for a module</summary>
 /// <param name="module">Module to add handlers to (usually "this")</param>
 /// <param name="configuration">Forms authentication configuration</param>
 public static void Enable(INancyModule module, CustomAuthenticationConfiguration configuration)
 {
     if (module == null)
     {
         throw new ArgumentNullException("module");
     }
     if (configuration == null)
     {
         throw new ArgumentNullException("configuration");
     }
     if (!configuration.IsValid)
     {
         throw new ArgumentException("Configuration is invalid", "configuration");
     }
     module.RequiresAuthentication();
     CustomAuthenticationProvider.currentConfiguration = configuration;
     module.Before.AddItemToStartOfPipeline(CustomAuthenticationProvider.GetLoadAuthenticationHook(configuration));
     if (configuration.DisableRedirect)
     {
         return;
     }
     module.After.AddItemToEndOfPipeline(CustomAuthenticationProvider.GetRedirectToLoginHook(configuration));
 }