Example #1
0
 /// <summary>
 /// This module requires authentication and any one of certain claims to be present.
 /// </summary>
 /// <param name="module">Module to enable</param>
 /// <param name="requiredClaims">Claim(s) required</param>
 public static void RequiresAnyClaim(this INancyModule module, IEnumerable <string> requiredClaims)
 {
     module.AddBeforeHookOrExecute(SecurityHooks.RequiresAuthentication(), "Requires Authentication");
     module.AddBeforeHookOrExecute(SecurityHooks.RequiresAnyClaim(requiredClaims), "Requires Any Claim");
 }
Example #2
0
 /// <summary>
 /// This module requires claims to be validated
 /// </summary>
 /// <param name="module">Module to enable</param>
 /// <param name="isValid">Claims validator</param>
 public static void RequiresValidatedClaims(this INancyModule module, Func <IEnumerable <string>, bool> isValid)
 {
     module.AddBeforeHookOrExecute(SecurityHooks.RequiresAuthentication(), "Requires Authentication");
     module.AddBeforeHookOrExecute(SecurityHooks.RequiresValidatedClaims(isValid), "Requires Validated Claim");
 }
 /// <summary>
 /// This module requires https.
 /// </summary>
 /// <param name="module">The <see cref="INancyModule"/> that requires HTTPS.</param>
 /// <param name="redirect"><see langword="true"/> if the user should be redirected to HTTPS if the incoming request was made using HTTP, otherwise <see langword="false"/> if <see cref="HttpStatusCode.Forbidden"/> should be returned.</param>
 /// <param name="httpsPort">The HTTPS port number to use</param>
 public static void RequiresHttps(this INancyModule module, bool redirect, int httpsPort)
 {
     module.Before.AddItemToEndOfPipeline(SecurityHooks.RequiresHttps(redirect, httpsPort));
 }
Example #4
0
 /// <summary>
 /// This module requires authentication
 /// </summary>
 /// <param name="module">Module to enable</param>
 public static void RequiresAuthentication(this INancyModule module)
 {
     module.AddBeforeHookOrExecute(SecurityHooks.RequiresAuthentication(), "Requires Authentication");
 }
 /// <summary>
 /// This module requires authentication and any one of certain claims to be present.
 /// </summary>
 /// <param name="module">Module to enable</param>
 /// <param name="requiredClaims">Claim(s) required</param>
 public static void RequiresAnyClaim(this INancyModule module, params Predicate <Claim>[] requiredClaims)
 {
     module.AddBeforeHookOrExecute(SecurityHooks.RequiresAuthentication(), "Requires Authentication");
     module.AddBeforeHookOrExecute(SecurityHooks.RequiresAnyClaim(requiredClaims), "Requires Any Claim");
 }
Example #6
0
 /// <summary>
 /// This module requires claims to be validated
 /// </summary>
 /// <param name="module">Module to enable</param>
 /// <param name="isValid">Claims validator</param>
 public static void RequiresValidatedClaims(this INancyModule module, Func <IEnumerable <string>, bool> isValid)
 {
     module.Before.AddItemToStartOfPipeline(SecurityHooks.RequiresValidatedClaims(isValid));
     module.Before.AddItemToStartOfPipeline(SecurityHooks.RequiresAuthentication());
 }
Example #7
0
 /// <summary>
 /// This module requires authentication and any one of certain claims to be present.
 /// </summary>
 /// <param name="module">Module to enable</param>
 /// <param name="requiredClaims">Claim(s) required</param>
 public static void RequiresAnyClaim(this INancyModule module, IEnumerable <string> requiredClaims)
 {
     module.Before.AddItemToEndOfPipeline(SecurityHooks.RequiresAuthentication());
     module.Before.AddItemToEndOfPipeline(SecurityHooks.RequiresAnyClaim(requiredClaims));
 }
Example #8
0
 /// <summary>
 /// This module requires authentication
 /// </summary>
 /// <param name="module">Module to enable</param>
 public static void RequiresAuthentication(this INancyModule module)
 {
     module.Before.AddItemToEndOfPipeline(SecurityHooks.RequiresAuthentication());
 }
Example #9
0
 /// <summary>
 /// This module requires authentication and any one of certain roles to be present.
 /// </summary>
 /// <param name="module">Module to enable</param>
 /// <param name="requiredRoles">Role(s) at least one of which is required</param>
 public static void RequiresAnyRole(this INancyModule module, params string[] requiredRoles)
 {
     module.AddBeforeHookOrExecute(SecurityHooks.RequiresAuthentication(), "Requires Authentication");
     module.AddBeforeHookOrExecute(SecurityHooks.RequiresAnyRole(requiredRoles), "Requires Any Role");
 }