Example #1
0
 public KeysController(ITweek tweek, IContextDriver contextDriver, CheckReadConfigurationAccess checkAccess)
 {
     _tweek         = tweek;
     _checkAccess   = checkAccess;
     _contextDriver = contextDriver;
 }
Example #2
0
        private IContextDriver CreateInputValidationDriverDecorator(IServiceProvider provider, IContextDriver driver)
        {
            var mode = match(Configuration["Context:Validation:Mode"]?.ToLower(),
                             with("flexible", (_) => Some(SchemaValidation.Mode.AllowUndefinedProperties)),
                             with("strict", (_) => Some(SchemaValidation.Mode.Strict)),
                             with("off", (_) => Option <SchemaValidation.Mode> .None),
                             with((string)null, (_) => Option <SchemaValidation.Mode> .None),
                             (raw) => throw new ArgumentException($"Invalid context validation mode ${raw}")
                             );


            return(match(mode, (Func <SchemaValidation.Mode, IContextDriver>)((m) =>
            {
                var reportOnly = Configuration["Context:Validation:ErrorPolicy"]?.ToLower() == "bypass_log";
                var logger = loggerFactory.CreateLogger <InputValidationContextDriver>();
                var tweek = provider.GetService <ITweek>();
                var rulesRepository = provider.GetService <IRulesRepository>();
                var driverWithValidation = new InputValidationContextDriver(
                    (IContextDriver)driver,
                    CreateSchemaProvider(tweek, rulesRepository, m),
                    reportOnly
                    );

                driverWithValidation.OnValidationFailed += (message) => logger.LogWarning(message);
                return driverWithValidation;
            }), () => driver));
        }
 public QueryHealthCheck(ITweek tweek, IContextDriver contextDriver)
 {
     _tweek         = tweek;
     _contextDriver = contextDriver;
 }
Example #4
0
 public ContextController(IContextDriver contextDriver, JsonSerializer serializer, CheckWriteContextAccess checkAccess)
 {
     _contextDriver = contextDriver;
     _checkAccess   = checkAccess;
 }