public AppKeeper(ILoxy loxy) { if (loxy == null) { throw new ArgumentNullException(nameof(loxy)); } _loxy = loxy; }
public LoggerProxy(ILoxy loxy, Action <LoggerProxyOptions> config) { LoggerProxyOptions defaultOptions = new LoggerProxyOptions(); config(defaultOptions); _loxy = loxy; Options = defaultOptions; }
public LoggerFactoryProxy(ILoxy eventLogger, Action <LoggerProxyOptions> config) { Id = new Guid(); _events = eventLogger; LoggerProxyOptions defaultOptions = new LoggerProxyOptions(); config(defaultOptions); Options = defaultOptions; }
protected override async Task OnBefore(HttpContext context) { _loxy = (ILoxy)context.RequestServices.GetService(typeof(ILoxy)); if (_loxy == null) { throw new LoxyNotFoundException(); } if (_loxy.Sinks == null || _loxy.Sinks.Count == 0) { throw new NoSinksRegisteredException(); } }
public void ConfigureServices(IServiceCollection services) { ConfigureSerilog(); services.AddLogging(x => x.AddSerilog()); services.TryAddSingleton <HateoasService>(); services.AddRequestInfo(); services.AddLoxy() .Sinks.AddJsonSink() .WithMinimumLevel(LogLevel.Debug) .WithExtendedLevel(LogLevel.Error) .WithJsonFormatting(Formatting.Indented); // Configurations services.AddOptions <GtkOptions>() .Bind(Config.GetSection("Gatekeeper")) .ValidateEagerly(); // Stores services.AddSingleton <IResourceStore>(_ => new InMemoryResourceStore(GetTestResources())); services.AddSingleton <IRoleStore>(_ => new InMemoryRoleStore(GetTestRoles())); services .AddSingleton <ICredentialStore>(serviceCollection => { ISessionStore sessionStore = serviceCollection.GetService <ISessionStore>(); return(new InMemoryCredentialStore(sessionStore, GetTestCredentials())); }); services.AddSingleton <ISessionStore>(_ => new InMemorySessionStore()); services.AddSingleton <ILoginAttemptStore>(_ => new InMemoryLoginAttemptStore()); services.AddSingleton <ICredentialPenaltyStore>(_ => new InMemoryCredentialPenaltyStore()); services.AddTransient <ILoginAttemptLimitingService, DefaultLoginAttemptLimitingService>(); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(x => { x.Events = new JwtBearerEvents { OnTokenValidated = async context => { ILoxy loxy = context.HttpContext.RequestServices.GetService <ILoxy>(); loxy.Raise(new Event(LogLevel.Information, "Gatekeeper", context.Principal.GetCredentialId())); } }; x.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, //ValidateAudience = true, ValidateLifetime = true, ValidateIssuerSigningKey = true, ValidIssuer = Config["Auth:Issuer"], ValidAudience = Config["Auth:Audience"], IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Config["Auth:SigningSecret"])), ClockSkew = TimeSpan.Zero }; }); services.AddGatekeeper(); services.AddControllers(conf => { conf.Filters.Add <GtkActionFilter>(); conf.Filters.Add <HateoasFilter>(); }); }
public LoggerProxy(ILoxy loxy, LoggerProxyOptions options) { _loxy = loxy; Options = options; }
public LoggerProxy(ILoxy loxy) { _loxy = loxy; Options = new LoggerProxyOptions(); }
public ValuesController(ILoxy loxy) { _loxy = loxy; }
public LoggerFactoryProxy(ILoxy eventLogger) { Id = new Guid(); _events = eventLogger; }
public LoggerFactoryProxy(ILoxy eventLogger, LoggerProxyOptions options) { Id = new Guid(); _events = eventLogger; Options = options; }
public LoggerProviderProxy(ILoxy eventLogger) { Id = new Guid(); _events = eventLogger; }
public static DbContextOptionsBuilder UseLoxyAsLoggerFactory(this DbContextOptionsBuilder options, ILoxy loxy, string logCategory) { options.UseLoggerFactory( loxy.AsLoggerFactory(proxy => proxy.WithCategory(logCategory) .WithStateFormatterFactory(new EfStateFormatterFactory()) // EXPERIMENTAL SHIT, TO BE SURE IT WORKS YOU ARE BETTER OFF USING THE DEFAULT StateFormatter ) ); return(options); }