示例#1
0
        protected virtual Task ValidatePolicyAsync(ConfigurationValidationContext <Client> context)
        {
            if (context.Item.Policy == null)
            {
                context.SetError($"Policy is required, but no policy is configured.");
                return(Task.CompletedTask);
            }
            ConfigurationValidationContext <Policy> policyContext = new ConfigurationValidationContext <Policy>(context.Item.Policy);

            _policyConfigurationValidator.ValidateAsync(policyContext);

            if (!policyContext.IsValid)
            {
                context.SetError(policyContext.ErrorMessage);
            }
            return(Task.CompletedTask);
        }
示例#2
0
 protected virtual Task ValidateRoleAsync(ConfigurationValidationContext <Policy> context)
 {
     if (context.Item.Roles.Count == 0)
     {
         context.SetError($"At least on Role is required, but no role is configured.");
         return(Task.CompletedTask);
     }
     return(Task.CompletedTask);
 }
示例#3
0
 protected virtual Task ValidateCycliqueRoleAsync(ConfigurationValidationContext <Policy> context)
 {
     foreach (Role role in context.Item.Roles)
     {
         if (!CheckCircularReference(role))
         {
             context.SetError($"Circular reference detected. Please avoid circular references.");
             return(Task.CompletedTask);
         }
     }
     return(Task.CompletedTask);
 }