/// <summary>
 /// Set up the <paramref name="policyBuilder"/> to require an administrator.
 /// </summary>
 /// <param name="policyBuilder">Used for building policies during application startup.</param>
 public static AuthorizationPolicyBuilder RequireAdmin(this AuthorizationPolicyBuilder policyBuilder)
 {
     policyBuilder.RequireAuthenticatedUser();
     policyBuilder.RequireAssertion(context => {
         if (context.HasFailed)
         {
             return(true);
         }
         return(context.User.IsAdmin());
     });
     return(policyBuilder);
 }
Esempio n. 2
0
 /// <summary>
 /// Adds a <see cref="Infrastructure.DenyAnonymousAuthorizationRequirement"/> to the current instance.
 /// </summary>
 /// <returns>A reference to this instance after the operation has completed.</returns>
 public AcceptancePolicyBuilder RequireAuthenticatedUser()
 {
     _builder.RequireAuthenticatedUser();
     return(this);
 }