// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddSwaggerDocument( (config) => { config.DocumentProcessors.Add( new SecurityDefinitionAppender("ApiKey", new NSwag.OpenApiSecurityScheme { Type = NSwag.OpenApiSecuritySchemeType.ApiKey, Name = "Api-Key", In = NSwag.OpenApiSecurityApiKeyLocation.Header, })); config.OperationProcessors.Add(new OperationSecurityScopeProcessor("ApiKey")); config.PostProcess = (document) => { document.Info.Version = "v1"; document.Info.Title = "SimpleAuthService API"; document.Info.Description = "A simple identity management dan authentication service."; document.Info.Contact = new NSwag.OpenApiContact() { Name = "Firdaus Bisma Suryakusuma", Email = "*****@*****.**" }; }; }); var useCaseBootstrapper = new Bootstrapper(); services.AddSingleton(useCaseBootstrapper.Mediator); var apiKeyDbContext = new ApiKeyDbContext(); services.AddSingleton(apiKeyDbContext); services.AddControllers(); services.AddSingleton <IMapper>(new Mapper(new MapperConfig().GetConfiguration())); }
public ApiKeyMiddleware( RequestDelegate next, ApiKeyDbContext apiKeyDbContext) : base(next) { _apiKeyDbContext = apiKeyDbContext; }