예제 #1
0
        public static DataProtectionKeysDbContext DataProtectionKeys(IServiceProvider x)
        {
            var config  = new StandardEfDbConfig(x.GetRequiredService <IConfiguration>(), DatabaseConnectionStringNames.DataProtectionKeys);
            var builder = new SqlServerDbContextOptionsBuilder(config, x.GetRequiredService <ILoggerFactory>());

            return(new DataProtectionKeysDbContext(builder.Build()));
        }
예제 #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            services.AddSeriLog(Configuration);

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "WorkFlow");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new WorkflowDbContext(builder.Build());
                return(result);
            });

            services.AddSingleton <IUtcDateTimeProvider, StandardUtcDateTimeProvider>();

            services.AddScoped <HttpPostKeysLastAuthorise, HttpPostKeysLastAuthorise>();
            services.AddScoped <IKeysLastSignatureValidator, KeysLastSignatureValidator>();
            services.AddScoped <IKeysLastAuthorisationWriter, KeysLastAuthorisationWriter>();

            services.AddSwaggerGen(o =>
            {
                o.SwaggerDoc("v1", new OpenApiInfo {
                    Title = Title, Version = "v1"
                });
            });
        }
예제 #3
0
        public static void ConfigureServices(IServiceCollection services)
        {
            services.AddSeriLog(Configuration);
            services.AddSingleton(Configuration);
            services.AddTransient <App>();

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "Content");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new ExposureContentDbContext(builder.Build());
                return(result);
            });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "Workflow");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new WorkflowDbContext(builder.Build());
                return(result);
            });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "Icc");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new IccBackendContentDbContext(builder.Build());
                return(result);
            });
        }
예제 #4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddSeriLog(Configuration);

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "WorkFlow");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new WorkflowDbContext(builder.Build());
                return(result);
            });

            services.AddSingleton <IUtcDateTimeProvider, StandardUtcDateTimeProvider>();
            services.AddSingleton <IGeanTekListValidationConfig, StandardGeanCommonWorkflowConfig>();
            services.AddSingleton <ITemporaryExposureKeyValidator, TemporaryExposureKeyValidator>();
            services.AddSingleton <ITemporaryExposureKeyValidatorConfig, TemporaryExposureKeyValidatorConfig>();

            services.AddScoped <HttpPostKeysLastReleaseTeksCommand, HttpPostKeysLastReleaseTeksCommand>();

            services.AddScoped <IKeysLastReleaseTeksValidator, KeysLastReleaseTeksValidator>();
            services.AddScoped <IKeysLastSignatureValidator, FakeKeysLastSignatureValidator>();

            services.AddScoped <HttpPostKeysLastRegisterSecret, HttpPostKeysLastRegisterSecret>();
            services.AddScoped <IKeysLastSecretWriter, KeysLastSecretWriter>();
            services.AddScoped <IKeysLastSecretConfig, StandardKeysLastSecretConfig>();
            services.AddScoped <IKeysLastTekWriter, FakeKeysLastTekWriter>();

            services.AddSwaggerGen(o =>
            {
                o.SwaggerDoc("v1", new OpenApiInfo {
                    Title = Title, Version = "v1"
                });
            });
        }
예제 #5
0
        public CreateWorkflowDatabase(IConfiguration configuration)
        {
            var config  = new StandardEfDbConfig(configuration, "Workflow");
            var builder = new SqlServerDbContextOptionsBuilder(config);

            _Provider = new WorkflowDbContext(builder.Build());
        }
예제 #6
0
        public CreateIccDatabase(IConfiguration configuration)
        {
            var config  = new StandardEfDbConfig(configuration, "Icc");
            var builder = new SqlServerDbContextOptionsBuilder(config);

            _Provider = new IccBackendContentDbContext(builder.Build());
        }
예제 #7
0
        public void ConfigureServices(IServiceCollection services)
        {
            ComponentsContainerHelper.RegisterDefaultServices(services);

            services.AddSeriLog(Configuration);

            services.AddControllers(options => { options.RespectBrowserAcceptHeader = true; });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "Content");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new ExposureContentDbContext(builder.Build());
                result.BeginTransaction();
                return(result);
            });

            services.AddSingleton <IUtcDateTimeProvider>(new StandardUtcDateTimeProvider());
            services.AddSingleton <IPublishingId, StandardPublishingIdFormatter>();

            services.AddScoped <HttpGetCdnManifestCommand, HttpGetCdnManifestCommand>();
            services.AddScoped <HttpGetCdnContentCommand <AppConfigContentEntity>, HttpGetCdnContentCommand <AppConfigContentEntity> >();
            services.AddScoped <HttpGetCdnContentCommand <ResourceBundleContentEntity>, HttpGetCdnContentCommand <ResourceBundleContentEntity> >();
            services.AddScoped <HttpGetCdnContentCommand <RiskCalculationContentEntity>, HttpGetCdnContentCommand <RiskCalculationContentEntity> >();
            services.AddScoped <HttpGetCdnContentCommand <ExposureKeySetContentEntity>, HttpGetCdnContentCommand <ExposureKeySetContentEntity> >();

            services.AddScoped <IReader <ManifestEntity>, SafeBinaryContentDbReader <ManifestEntity> >();
            services.AddScoped <IReader <AppConfigContentEntity>, SafeBinaryContentDbReader <AppConfigContentEntity> >();
            services.AddScoped <IReader <ResourceBundleContentEntity>, SafeBinaryContentDbReader <ResourceBundleContentEntity> >();
            services.AddScoped <IReader <RiskCalculationContentEntity>, SafeBinaryContentDbReader <RiskCalculationContentEntity> >();
            services.AddScoped <IReader <ExposureKeySetContentEntity>, SafeBinaryContentDbReader <ExposureKeySetContentEntity> >();
        }
예제 #8
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddScoped(x => DbContextStartup.Workflow(x, false));
            services.AddScoped(x => DbContextStartup.Content(x, false));
            services.AddScoped(x => DbContextStartup.Publishing(x, false));

            services.AddTransient <ContentValidator>();
            services.AddTransient <ContentInsertDbCommand>();

            services.NlSignerStartup(_Configuration.UseCertificatesFromResources());
            services.GaSignerStartup(_Configuration.UseCertificatesFromResources());

            // Database Scoping
            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(_Configuration, "WorkFlow");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new WorkflowDbContext(builder.Build());
                result.BeginTransaction();
                return(result);
            });

            services.AddScoped <IUtcDateTimeProvider, StandardUtcDateTimeProvider>();
            services.AddTransient <IPublishingIdService, Sha256HexPublishingIdService>();
            services.AddTransient <ZippedSignedContentFormatter>();

            services.AddControllersWithViews();
        }
예제 #9
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers(options => { options.RespectBrowserAcceptHeader = true; });

            services.AddControllers();

            // Database Scoping
            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "Icc");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new IccBackendContentDbContext(builder.Build());
                result.BeginTransaction();
                return(result);
            });
            services.AddScoped <IEfDbConfig>(x => new StandardEfDbConfig(Configuration, "Icc"));
            services.AddScoped <ProvisionDatabasesCommandIcc, ProvisionDatabasesCommandIcc>();
            services.AddScoped <IUtcDateTimeProvider, StandardUtcDateTimeProvider>();
            services.AddScoped <IRandomNumberGenerator, RandomNumberGenerator>();
            services.AddScoped <IBasicAuthenticationConfig, BasicAuthenticationConfig>();
            services.AddScoped <IIccService, IccService>();
            services.AddScoped <AppBackendService, AppBackendService>();
            services.AddAuthentication("IccAuthentication")
            .AddScheme <AuthenticationSchemeOptions, IccAuthenticationHandler>("IccAuthentication", null);

            services.AddCors();

            services.AddSwaggerGen(o =>
            {
                o.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title       = "Dutch Exposure Notification ICC API (inc. dev support)",
                    Version     = "v1",
                    Description = "This specification describes the interface between the Dutch exposure notification app backend, ICC Webportal and the ICC backend service.",
                    Contact     = new OpenApiContact
                    {
                        Name = "Ministerie van Volksgezondheid Welzijn en Sport backend repository", //TODO looks wrong?
                        Url  = new Uri("https://github.com/minvws/nl-covid19-notification-app-backend"),
                    },
                    License = new OpenApiLicense
                    {
                        Name = "European Union Public License v. 1.2",
                        //TODO this should be https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
                        Url = new Uri("https://github.com/minvws/nl-covid19-notification-app-backend/blob/master/LICENSE.txt")
                    },
                });
                o.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "NL.Rijksoverheid.ExposureNotification.BackEnd.Components.xml"));
                o.AddSecurityDefinition("Icc", new OpenApiSecurityScheme
                {
                    Description = "Icc Code Authentication",
                    Name        = "Authorization",
                    In          = ParameterLocation.Header,
                    Type        = SecuritySchemeType.ApiKey,
                    Scheme      = "IccAuthentication"
                });
                o.OperationFilter <SecurityRequirementsOperationFilter>();
            });
        }
예제 #10
0
        public CreateContentDatabase(IConfiguration configuration, IUtcDateTimeProvider dateTimeProvider, IContentSigner signer)
        {
            var config  = new StandardEfDbConfig(configuration, "Content");
            var builder = new SqlServerDbContextOptionsBuilder(config);

            _DbContextProvider = new ExposureContentDbContext(builder.Build());
            _DateTimeProvider  = dateTimeProvider;
            _Formatter         = new StandardContentEntityFormatter(new ZippedSignedContentFormatter(signer), new StandardPublishingIdFormatter());
        }
예제 #11
0
        public WorkflowDatabaseCreateCommand(IConfiguration configuration, ITekValidatorConfig tekValidatorConfig, ILabConfirmationIdService labConfirmationIdService, IWorkflowConfig workflowConfig)
        {
            _TekValidatorConfig       = tekValidatorConfig ?? throw new ArgumentNullException(nameof(tekValidatorConfig));
            _LabConfirmationIdService = labConfirmationIdService ?? throw new ArgumentNullException(nameof(labConfirmationIdService));
            _WorkflowConfig           = workflowConfig ?? throw new ArgumentNullException(nameof(workflowConfig));
            var config  = new StandardEfDbConfig(configuration, "Workflow");
            var builder = new SqlServerDbContextOptionsBuilder(config);

            _Provider = new WorkflowDbContext(builder.Build());
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ComponentsContainerHelper.RegisterDefaultServices(services);

            services.AddControllers();

            services.AddSeriLog(Configuration);
            services.AddBasicAuthentication();

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "WorkFlow");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new WorkflowDbContext(builder.Build());
                result.Database.BeginTransaction();
                return(result);
            });

            services.AddSingleton <IUtcDateTimeProvider, StandardUtcDateTimeProvider>();

            services.AddScoped <HttpPostAuthorise, HttpPostAuthorise>();
            services.AddScoped <ISignatureValidator, SignatureValidator>();
            services.AddScoped <IAuthorisationWriter, AuthorisationWriter>();

            services.AddSwaggerGen(o =>
            {
                o.SwaggerDoc("v1", new OpenApiInfo {
                    Title = Title, Version = "v1"
                });

                o.AddSecurityDefinition("basic", new OpenApiSecurityScheme
                {
                    Name        = "Authorization",
                    Type        = SecuritySchemeType.Http,
                    Scheme      = "basic",
                    In          = ParameterLocation.Header,
                    Description = "Basic Authorization header using the Bearer scheme."
                });

                o.AddSecurityRequirement(new OpenApiSecurityRequirement
                {
                    {
                        new OpenApiSecurityScheme
                        {
                            Reference = new OpenApiReference
                            {
                                Type = ReferenceType.SecurityScheme,
                                Id   = "basic"
                            }
                        },
                        new string[] {}
                    }
                });
            });
        }
예제 #13
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ComponentsContainerHelper.RegisterDefaultServices(services);

            services.AddBasicAuthentication();
            services.AddSeriLog(Configuration);
            services.AddControllers();
            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "Content");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new ExposureContentDbContext(builder.Build());
                result.BeginTransaction();
                return(result);
            });

            services.AddScoped <HttpPostContentReciever <ManifestEntity>, HttpPostContentReciever <ManifestEntity> >();
            services.AddScoped <HttpPostContentReciever <AppConfigContentEntity>, HttpPostContentReciever <AppConfigContentEntity> >();
            services.AddScoped <HttpPostContentReciever <ResourceBundleContentEntity>, HttpPostContentReciever <ResourceBundleContentEntity> >();
            services.AddScoped <HttpPostContentReciever <RiskCalculationContentEntity>, HttpPostContentReciever <RiskCalculationContentEntity> >();
            services.AddScoped <HttpPostContentReciever <ExposureKeySetContentEntity>, HttpPostContentReciever <ExposureKeySetContentEntity> >();

            services.AddSwaggerGen(o =>
            {
                o.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title   = "Azure CDN Data Receiver API",
                    Version = "v1",
                });

                o.AddSecurityDefinition("basic", new OpenApiSecurityScheme
                {
                    Name        = "Authorization",
                    Type        = SecuritySchemeType.Http,
                    Scheme      = "basic",
                    In          = ParameterLocation.Header,
                    Description = "Basic Authorization header using the Bearer scheme."
                });

                o.AddSecurityRequirement(new OpenApiSecurityRequirement
                {
                    {
                        new OpenApiSecurityScheme
                        {
                            Reference = new OpenApiReference
                            {
                                Type = ReferenceType.SecurityScheme,
                                Id   = "basic"
                            }
                        },
                        new string[] {}
                    }
                });
            });
        }
예제 #14
0
        public static StatsDbContext Stats(IServiceProvider x, bool beginTrans = true)
        {
            var config  = new StandardEfDbConfig(x.GetRequiredService <IConfiguration>(), DatabaseConnectionStringNames.Stats);
            var builder = new SqlServerDbContextOptionsBuilder(config, x.GetRequiredService <ILoggerFactory>());
            var result  = new StatsDbContext(builder.Build());

            if (beginTrans)
            {
                result.BeginTransaction();
            }
            return(result);
        }
        public IccDatabaseCreateCommand(IConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            var config  = new StandardEfDbConfig(configuration, "Icc");
            var builder = new SqlServerDbContextOptionsBuilder(config);

            _Provider = new IccBackendContentDbContext(builder.Build());
        }
예제 #16
0
 private static void Configure(IServiceCollection services, IConfigurationRoot configuration)
 {
     services.AddScoped(x =>
     {
         var config  = new StandardEfDbConfig(configuration, "Workflow");
         var builder = new SqlServerDbContextOptionsBuilder(config);
         var result  = new WorkflowDbContext(builder.Build());
         return(result);
     });
     services.AddTransient <GenerateTeksCommand>();
     services.AddSingleton <IConfiguration>(configuration);
 }
        // 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.AddControllers();
            services.AddSeriLog(Configuration);

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "WorkFlow");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new WorkflowDbContext(builder.Build());
                result.BeginTransaction();
                return(result);
            });

            services.AddBasicAuthentication();

            services.AddScoped <PurgeExpiredSecretsDbCommand, PurgeExpiredSecretsDbCommand>();

            services.AddSwaggerGen(o =>
            {
                o.SwaggerDoc("v1", new OpenApiInfo {
                    Title = Title, Version = "v1"
                });

                o.AddSecurityDefinition("basic", new OpenApiSecurityScheme
                {
                    Name        = "Authorization",
                    Type        = SecuritySchemeType.Http,
                    Scheme      = "basic",
                    In          = ParameterLocation.Header,
                    Description = "Basic Authorization header using the Bearer scheme."
                });

                o.AddSecurityRequirement(new OpenApiSecurityRequirement
                {
                    {
                        new OpenApiSecurityScheme
                        {
                            Reference = new OpenApiReference
                            {
                                Type = ReferenceType.SecurityScheme,
                                Id   = "basic"
                            }
                        },
                        new string[] {}
                    }
                });
            });
        }
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddScoped <IJsonSerializer, StandardJsonSerializer>();

            services.AddControllers();

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(_Configuration, "WorkFlow");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new WorkflowDbContext(builder.Build());
                result.BeginTransaction();
                return(result);
            });

            services.AddSingleton <IUtcDateTimeProvider, StandardUtcDateTimeProvider>();
            services.AddSingleton <IGeanTekListValidationConfig, StandardGeanCommonWorkflowConfig>();
            services.AddSingleton <ITemporaryExposureKeyValidator, TemporaryExposureKeyValidator>();
            services.AddSingleton <ITemporaryExposureKeyValidatorConfig, TemporaryExposureKeyValidatorConfig>();

            services.AddScoped <HttpPostReleaseTeksCommand, HttpPostReleaseTeksCommand>();

            services.AddScoped <IReleaseTeksValidator, ReleaseTeksValidator>();
            services.AddScoped <ISignatureValidator, SignatureValidator>();

            _SignatureValidationEnabled = _Configuration.GetValue("ValidatePostKeysSignature", true);
            if (_SignatureValidationEnabled)
            {
                services.AddScoped <ISignatureValidator, SignatureValidator>();
            }
            else
            {
                services.AddScoped <ISignatureValidator, DoNotValidateSignatureValidator>();
            }

            services.AddScoped <HttpPostRegisterSecret, HttpPostRegisterSecret>();
            services.AddScoped <ISecretWriter, SecretWriter>();
            services.AddScoped <ITekWriter, TekWriter>();
            services.AddScoped <RandomNumberGenerator, RandomNumberGenerator>();
            services.AddScoped <IRandomNumberGenerator, RandomNumberGenerator>();

            services.AddScoped <HttpPostDecoyKeysCommand, HttpPostDecoyKeysCommand>();
            services.AddScoped <IDecoyKeysConfig, StandardDecoyKeysConfig>();

            services.AddSwaggerGen(o => { o.SwaggerDoc("v1", new OpenApiInfo {
                    Title = Title, Version = "v1"
                }); });
        }
예제 #19
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ComponentsContainerHelper.RegisterDefaultServices(services);

            services.AddControllers();
            services.AddSeriLog(Configuration);

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "WorkFlow");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new WorkflowDbContext(builder.Build());
                result.BeginTransaction();
                return(result);
            });
            services.AddScoped <JwtService, JwtService>();
            services.AddAuthentication("icc_jwt")
            .AddScheme <AuthenticationSchemeOptions, JwtAuthorizationHandler>("icc_jwt", null);

            services.AddSingleton <IUtcDateTimeProvider, StandardUtcDateTimeProvider>();
            services.AddSingleton <IGeanTekListValidationConfig, StandardGeanCommonWorkflowConfig>();
            services.AddSingleton <ITemporaryExposureKeyValidator, TemporaryExposureKeyValidator>();
            services.AddSingleton <ITemporaryExposureKeyValidatorConfig, TemporaryExposureKeyValidatorConfig>();

            services.AddScoped <HttpPostReleaseTeksCommand, HttpPostReleaseTeksCommand>();

            services.AddScoped <IReleaseTeksValidator, ReleaseTeksValidator>();
            services.AddScoped <ISignatureValidator, SignatureValidator>();

            services.AddScoped <HttpPostRegisterSecret, HttpPostRegisterSecret>();
            services.AddScoped <ISecretWriter, SecretWriter>();
            services.AddScoped <ISecretConfig, StandardSecretConfig>();
            services.AddScoped <ITekWriter, TekWriter>();
            services.AddScoped <RandomNumberGenerator, RandomNumberGenerator>();

            services.AddSwaggerGen(o =>
            {
                o.SwaggerDoc("v1", new OpenApiInfo {
                    Title = Title, Version = "v1"
                });
            });
        }
        private static void Configure(IServiceCollection services, IConfigurationRoot configuration)
        {
            services.AddLogging();
            services.AddSingleton <IConfiguration>(configuration);
            services.AddTransient <ManifestBatchJob>();
            services.AddTransient <ManifestBuilderAndFormatter>();
            services.AddTransient <IContentEntityFormatter, StandardContentEntityFormatter>();
            services.AddTransient <ZippedSignedContentFormatter>();
            services.AddTransient <IPublishingId, StandardPublishingIdFormatter>();

            services.AddTransient <HttpGetCdnManifestCommand>();
            services.AddTransient <HttpGetCdnContentCommand>();

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(configuration, "Content");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new ContentDbContext(builder.Build());
                return(result);
            });
            services.AddTransient <ManifestBuilder>();
            services.AddSingleton <IUtcDateTimeProvider, StandardUtcDateTimeProvider>();
            if (configuration.GetValue("DevelopmentFlags:UseCertificatesFromResources", false))
            {
                if (configuration.GetValue("DevelopmentFlags:Azure", false))
                {
                    services.AddTransient <IContentSigner>(x => new CmsSigner(new AzureResourceCertificateProvider(new StandardCertificateLocationConfig(configuration, "Certificates:NL"))));
                }
                else
                {
                    services.AddTransient <IContentSigner>(x => new CmsSigner(new LocalResourceCertificateProvider(new StandardCertificateLocationConfig(configuration, "Certificates:NL"))));
                }
            }
            else
            {
                services.AddTransient <IContentSigner>(x
                                                       => new CmsSigner(new X509CertificateProvider(new CertificateProviderConfig(x.GetRequiredService <IConfiguration>(), "Certificates:NL"),
                                                                                                    x.GetRequiredService <ILogger <X509CertificateProvider> >())));
            }
            services.AddTransient <IJsonSerializer, StandardJsonSerializer>();
            services.AddSingleton <IGaenContentConfig, StandardGaenContentConfig>();
        }
        public void ConfigureServices(IServiceCollection services)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            services.AddLogging();

            services.AddTransient <IJsonSerializer, StandardJsonSerializer>();

            services.AddControllers(options => { options.RespectBrowserAcceptHeader = true; });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(_Configuration, "Content");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new ContentDbContext(builder.Build());
                result.BeginTransaction();
                return(result);
            });

            services.AddTransient <IHttpResponseHeaderConfig, HttpResponseHeaderConfig>();
            services.AddSingleton <IUtcDateTimeProvider>(new StandardUtcDateTimeProvider());
            services.AddTransient <IPublishingId, StandardPublishingIdFormatter>();

            services.AddScoped <HttpGetCdnManifestCommand>();
            services.AddScoped <HttpGetCdnContentCommand>();

            services.AddSwaggerGen(o =>
            {
                o.SwaggerDoc("v1", new OpenApiInfo {
                    Title = Title, Version = "v1"
                });
            });
        }
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddLogging();

            services.AddControllers(options =>
            {
                options.RespectBrowserAcceptHeader = true;
            });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(_Configuration, "WorkFlow");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new WorkflowDbContext(builder.Build());
                return(result);
            });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(_Configuration, "Content");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new ContentDbContext(builder.Build());
                return(result);
            });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(_Configuration, "PublishingJob");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new PublishingJobDbContext(builder.Build());
                return(result);
            });

            services.AddSingleton <IUtcDateTimeProvider, StandardUtcDateTimeProvider>();
            services.AddTransient(x =>
                                  new ExposureKeySetBatchJobMk2(
                                      x.GetService <IGaenContentConfig>(),
                                      x.GetService <IExposureKeySetBuilder>(),
                                      x.GetService <WorkflowDbContext>(),
                                      x.GetService <PublishingJobDbContext>(),
                                      x.GetService <ContentDbContext>(),
                                      x.GetService <IUtcDateTimeProvider>(),
                                      x.GetService <IPublishingId>(),
                                      x.GetService <ILogger <ExposureKeySetBatchJobMk2> >()
                                      ));

            if (_Configuration.GetValue("DevelopmentFlags:UseCertificatesFromResources", false))
            {
                if (_Configuration.GetValue("DevelopmentFlags:Azure", false))
                {
                    //AZURE

                    services.AddScoped <IExposureKeySetBuilder>(x =>
                                                                new ExposureKeySetBuilderV1(
                                                                    x.GetRequiredService <IExposureKeySetHeaderInfoConfig>(),
                                                                    new EcdSaSigner(new AzureResourceCertificateProvider(new StandardCertificateLocationConfig(_Configuration, "Certificates:GA"))),
                                                                    new CmsSigner(new AzureResourceCertificateProvider(new StandardCertificateLocationConfig(_Configuration, "Certificates:NL"))),
                                                                    x.GetRequiredService <IUtcDateTimeProvider>(), //TODO pass in time thru execute
                                                                    new GeneratedProtobufContentFormatter(),
                                                                    x.GetRequiredService <ILogger <ExposureKeySetBuilderV1> >()
                                                                    ));

                    services.AddScoped <IContentSigner>(x => new CmsSigner(new AzureResourceCertificateProvider(new StandardCertificateLocationConfig(_Configuration, "Certificates:NL"))));
                }
                else
                {
                    //UNIT TESTS, LOCAL DEBUG

                    services.AddScoped <IExposureKeySetBuilder>(x =>
                                                                new ExposureKeySetBuilderV1(
                                                                    x.GetRequiredService <IExposureKeySetHeaderInfoConfig>(),
                                                                    new EcdSaSigner(new LocalResourceCertificateProvider(new StandardCertificateLocationConfig(x.GetRequiredService <IConfiguration>(), "Certificates:GA"))),
                                                                    new CmsSigner(new LocalResourceCertificateProvider(new StandardCertificateLocationConfig(x.GetRequiredService <IConfiguration>(), "Certificates:NL"))),
                                                                    x.GetRequiredService <IUtcDateTimeProvider>(), //TODO pass in time thru execute
                                                                    new GeneratedProtobufContentFormatter(),
                                                                    x.GetRequiredService <ILogger <ExposureKeySetBuilderV1> >()
                                                                    ));

                    services.AddScoped <IContentSigner>(x => new CmsSigner(new LocalResourceCertificateProvider(new StandardCertificateLocationConfig(_Configuration, "Certificates:NL"))));
                }
            }
            else
            {
                //PROD
                services.AddScoped <IExposureKeySetBuilder>(x =>
                                                            new ExposureKeySetBuilderV1(
                                                                x.GetRequiredService <IExposureKeySetHeaderInfoConfig>(),
                                                                new EcdSaSigner(new X509CertificateProvider(new CertificateProviderConfig(x.GetRequiredService <IConfiguration>(), "Certificates:GA"), x.GetRequiredService <ILogger <X509CertificateProvider> >())),
                                                                new CmsSigner(new X509CertificateProvider(new CertificateProviderConfig(x.GetRequiredService <IConfiguration>(), "Certificates:NL"), x.GetRequiredService <ILogger <X509CertificateProvider> >())),
                                                                x.GetRequiredService <IUtcDateTimeProvider>(), //TODO pass in time thru execute
                                                                new GeneratedProtobufContentFormatter(),
                                                                x.GetRequiredService <ILogger <ExposureKeySetBuilderV1> >()
                                                                ));

                services.AddScoped <IContentSigner>(x => new CmsSigner(new X509CertificateProvider(new CertificateProviderConfig(x.GetRequiredService <IConfiguration>(), "Certificates:NL"), x.GetRequiredService <ILogger <X509CertificateProvider> >())));
            }

            services.AddScoped <IExposureKeySetHeaderInfoConfig, ExposureKeySetHeaderInfoConfig>();
            services.AddScoped <IPublishingId, StandardPublishingIdFormatter>();

            services.AddLogging();
            services.AddSingleton(_Configuration);
            services.AddTransient <ManifestBatchJob>();
            services.AddTransient <ManifestBuilder>();
            services.AddTransient <ManifestBuilderAndFormatter>();
            services.AddTransient <IContentEntityFormatter, StandardContentEntityFormatter>();
            services.AddTransient <ZippedSignedContentFormatter>();
            services.AddSingleton <IGaenContentConfig, StandardGaenContentConfig>();
            services.AddTransient <IJsonSerializer, StandardJsonSerializer>();
            services.AddSingleton(_Configuration);

            services.AddTransient <WorkflowDatabaseCreateCommand>();
            services.AddTransient <PublishingJobDatabaseCreateCommand>();
            services.AddTransient <IccDatabaseCreateCommand>();
            services.AddTransient <ContentDatabaseCreateCommand>();
            services.AddTransient <ProvisionDatabasesCommand>();
            services.AddSingleton <IUtcDateTimeProvider, StandardUtcDateTimeProvider>();
            services.AddTransient <IPublishingId, StandardPublishingIdFormatter>();
            services.AddTransient <ContentValidator>();
            services.AddTransient <ContentInsertDbCommand>();
            services.AddTransient <ZippedSignedContentFormatter>();

            services.AddSwaggerGen(o =>
            {
                o.SwaggerDoc("v1", new OpenApiInfo {
                    Title = Title, Version = "v1"
                });
            });
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSeriLog(Configuration);

            services.AddControllers();
            services.AddBasicAuthentication();

            services.AddScoped <HttpGetManifestBinaryContentCommand, HttpGetManifestBinaryContentCommand>();
            services.AddScoped <DynamicManifestReader, DynamicManifestReader>();
            services.AddScoped <ManifestBuilder, ManifestBuilder>();
            services.AddSingleton <IUtcDateTimeProvider>(new StandardUtcDateTimeProvider());
            services.AddSingleton <IPublishingId>(new StandardPublishingIdFormatter());
            services.AddSingleton <IGaenContentConfig>(new GaenContentConfig(Configuration));
            services.AddSingleton <IContentSigner, CmsSigner>();
            services.AddSingleton <ICertificateProvider, HsmCertificateProvider>();
            services.AddSingleton <IThumbprintConfig>(x => new CertificateProviderConfig(x.GetService <IConfiguration>(), "ExposureKeySets:Signing:NL"));

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "Content");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new ExposureContentDbContext(builder.Build());
                result.BeginTransaction();
                return(result);
            });

            services.AddScoped <GetActiveExposureKeySetsListCommand, GetActiveExposureKeySetsListCommand>();
            services.AddScoped <GetLatestContentCommand <AppConfigContentEntity>, GetLatestContentCommand <AppConfigContentEntity> >();
            services.AddScoped <GetLatestContentCommand <ResourceBundleContentEntity>, GetLatestContentCommand <ResourceBundleContentEntity> >();
            services.AddScoped <GetLatestContentCommand <RiskCalculationContentEntity>, GetLatestContentCommand <RiskCalculationContentEntity> >();

            services.AddScoped <HttpGetBinaryContentCommand <ExposureKeySetContentEntity>, HttpGetBinaryContentCommand <ExposureKeySetContentEntity> >();
            services.AddScoped <HttpGetBinaryContentCommand <AppConfigContentEntity>, HttpGetBinaryContentCommand <AppConfigContentEntity> >();
            services.AddScoped <HttpGetBinaryContentCommand <ResourceBundleContentEntity>, HttpGetBinaryContentCommand <ResourceBundleContentEntity> >();
            services.AddScoped <HttpGetBinaryContentCommand <RiskCalculationContentEntity>, HttpGetBinaryContentCommand <RiskCalculationContentEntity> >();

            services.AddScoped <IReader <ExposureKeySetContentEntity>, SafeBinaryContentDbReader <ExposureKeySetContentEntity> >();
            services.AddScoped <IReader <AppConfigContentEntity>, SafeBinaryContentDbReader <AppConfigContentEntity> >();
            services.AddScoped <IReader <ResourceBundleContentEntity>, SafeBinaryContentDbReader <ResourceBundleContentEntity> >();
            services.AddScoped <IReader <RiskCalculationContentEntity>, SafeBinaryContentDbReader <RiskCalculationContentEntity> >();


            services.AddSwaggerGen(o =>
            {
                o.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title   = Title,
                    Version = "v1",
                });

                o.AddSecurityDefinition("basic", new OpenApiSecurityScheme
                {
                    Name        = "Authorization",
                    Type        = SecuritySchemeType.Http,
                    Scheme      = "basic",
                    In          = ParameterLocation.Header,
                    Description = "Basic Authorization header using the Bearer scheme."
                });

                o.AddSecurityRequirement(new OpenApiSecurityRequirement
                {
                    {
                        new OpenApiSecurityScheme
                        {
                            Reference = new OpenApiReference
                            {
                                Type = ReferenceType.SecurityScheme,
                                Id   = "basic"
                            }
                        },
                        new string[] {}
                    }
                });
            });
        }
예제 #24
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers(options =>
            {
                options.RespectBrowserAcceptHeader = true;
            }).AddNewtonsoftJson(options =>
                                 options.SerializerSettings.ContractResolver =
                                     new CamelCasePropertyNamesContractResolver());

            services.AddControllers();

            services.AddSingleton <IUtcDateTimeProvider, StandardUtcDateTimeProvider>();
            services.AddSingleton <ILuhnModNConfig, LuhnModNConfig>();
            services.AddSingleton <IGaenContentConfig, GaenContentConfig>();
            services.AddSingleton <IExposureKeySetHeaderInfoConfig, HsmExposureKeySetHeaderInfoConfig>();
            services.AddSingleton <IExposureKeySetBatchJobConfig, ExposureKeySetBatchJobConfig>();
            services.AddSingleton <IPublishingId>(x => new StandardPublishingIdFormatter(new HardCodedSigner()));

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "Content");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new ExposureContentDbContext(builder.Build());
                result.BeginTransaction();
                return(result);
            });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "WorkFlow");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new WorkflowDbContext(builder.Build());
                result.BeginTransaction();
                return(result);
            });

            //Just for the Batch Job
            services.AddScoped <IEfDbConfig>(x => new StandardEfDbConfig(Configuration, "Job"));

            services.AddScoped <HttpPostKeysFirstGenerateTekSetsCommand, HttpPostKeysFirstGenerateTekSetsCommand>();
            services.AddScoped <HttpPostKeysFirstEscrowCommand, HttpPostKeysFirstEscrowCommand>();

            services.AddSingleton <IKeysFirstEscrowValidator, KeysFirstEscrowValidator>();
            services.AddSingleton <IKeysFirstAuthorisationTokenValidator, KeysFirstAuthorisationTokenLuhnModNValidator>();
            services.AddSingleton <IGeanTekListValidationConfig, StandardGeanCommonWorkflowConfig>();
            services.AddSingleton <ITemporaryExposureKeyValidator, TemporaryExposureKeyValidator>();
            services.AddSingleton <ITemporaryExposureKeyValidatorConfig, TemporaryExposureKeyValidatorConfig>();
            services.AddScoped <IKeysFirstEscrowWriter, KeysFirstEscrowInsertDbCommand>();
            services.AddScoped <ISigner, HardCodedSigner>();

            services.AddScoped <HttpPostKeysFirstAuthorisationCommand, HttpPostKeysFirstAuthorisationCommand>();
            services.AddScoped <IKeysFirstAuthorisationWriter, KeysFirstDbAuthoriseCommand>();

            //TODO services.AddScoped<HttpGetLatestManifestCommand, HttpGetLatestManifestCommand>();
            services.AddScoped <ManifestBuilder, ManifestBuilder>();
            services.AddScoped <GetActiveExposureKeySetsListCommand, GetActiveExposureKeySetsListCommand>();

            services.AddScoped <ExposureKeySetSafeReadCommand, ExposureKeySetSafeReadCommand>();
            services.AddScoped <SafeGetRiskCalculationConfigDbCommand, SafeGetRiskCalculationConfigDbCommand>();

            services.AddScoped <HttpPostRiskCalculationConfigCommand, HttpPostRiskCalculationConfigCommand>();
            services.AddScoped <RiskCalculationConfigValidator, RiskCalculationConfigValidator>();
            services.AddScoped <RiskCalculationConfigInsertDbCommand, RiskCalculationConfigInsertDbCommand>();

            services.AddScoped <HttpPostResourceBundleCommand, HttpPostResourceBundleCommand>();
            services.AddScoped <ResourceBundleInsertDbCommand, ResourceBundleInsertDbCommand>();
            services.AddScoped <ResourceBundleValidator, ResourceBundleValidator>();

            //services.AddScoped<SafeGetResourceBundleCommand, SafeGetResourceBundleCommand>();

            services.AddScoped <ProvisionDatabasesCommand, ProvisionDatabasesCommand>();
            services.AddScoped <GenerateKeysFirstTekSetsArgs, GenerateKeysFirstTekSetsArgs>();
            services.AddScoped <HttpPostGenerateExposureKeySetsCommand, HttpPostGenerateExposureKeySetsCommand>();
            services.AddScoped <HttpPostKeysFirstRandomAuthorisationCommand, HttpPostKeysFirstRandomAuthorisationCommand>();
            services.AddScoped <GenerateKeysFirstAuthorisations, GenerateKeysFirstAuthorisations>();

            services.AddScoped <HttpGetCdnContentCommand <ManifestEntity>, HttpGetCdnContentCommand <ManifestEntity> >();
            services.AddScoped <HttpGetCdnContentCommand <ExposureKeySetContentEntity>, HttpGetCdnContentCommand <ExposureKeySetContentEntity> >();
            services.AddScoped <HttpGetCdnContentCommand <RiskCalculationContentEntity>, HttpGetCdnContentCommand <RiskCalculationContentEntity> >();
            services.AddScoped <HttpGetCdnContentCommand <ResourceBundleContentEntity>, HttpGetCdnContentCommand <ResourceBundleContentEntity> >();
            services.AddScoped <HttpGetCdnContentCommand <AppConfigContentEntity>, HttpGetCdnContentCommand <AppConfigContentEntity> >();

            services.AddScoped <IReader <ManifestEntity>, DynamicManifestReader>();
            services.AddScoped <IReader <ExposureKeySetContentEntity>, SafeBinaryContentDbReader <ExposureKeySetContentEntity> >();
            services.AddScoped <IReader <ResourceBundleContentEntity>, SafeBinaryContentDbReader <ResourceBundleContentEntity> >();
            services.AddScoped <IReader <RiskCalculationContentEntity>, SafeBinaryContentDbReader <RiskCalculationContentEntity> >();
            services.AddScoped <IReader <AppConfigContentEntity>, SafeBinaryContentDbReader <AppConfigContentEntity> >();

            services.AddScoped <HttpPostKeysLastRegisterSecret, HttpPostKeysLastRegisterSecret>();
            services.AddScoped <RandomNumberGenerator, RandomNumberGenerator>();
            services.AddScoped <IKeysLastSecretConfig, StandardKeysLastSecretConfig>();

            services.AddScoped <IKeysLastSecretWriter, KeysLastSecretWriter>();

            services.AddScoped <KeysLastAuthorisationWriter, KeysLastAuthorisationWriter>();

            services.AddScoped <HttpPostKeysLastReleaseTeksCommand, HttpPostKeysLastReleaseTeksCommand>();
            services.AddScoped <IKeysLastReleaseTeksValidator, KeysLastReleaseTeksValidator>();
            services.AddScoped <IKeysLastSignatureValidator, FakeKeysLastSignatureValidator>();
            services.AddScoped <IKeysLastTekWriter, FakeKeysLastTekWriter>();

            services.AddScoped <HttpPostAppConfigCommand, HttpPostAppConfigCommand>();
            services.AddScoped <AppConfigInsertDbCommand, AppConfigInsertDbCommand>();
            services.AddScoped <AppConfigValidator, AppConfigValidator>();

            services.AddScoped <HttpPostKeysLastAuthorise, HttpPostKeysLastAuthorise>();
            services.AddScoped <IKeysLastAuthorisationWriter, KeysLastAuthorisationWriter>();
            services.AddScoped <IReleaseKeysAuthorizationValidator, FakeReleaseKeysAuthorizationValidator>();

            services.AddScoped <GetLatestContentCommand <ResourceBundleContentEntity>, GetLatestContentCommand <ResourceBundleContentEntity> >();
            services.AddScoped <GetLatestContentCommand <RiskCalculationContentEntity>, GetLatestContentCommand <RiskCalculationContentEntity> >();
            services.AddScoped <GetLatestContentCommand <AppConfigContentEntity>, GetLatestContentCommand <AppConfigContentEntity> >();

            services.AddScoped <IContentEntityFormatter, StandardContentEntityFormatter>();
            services.AddScoped <ZippedSignedContentFormatter, ZippedSignedContentFormatter>();


            services.AddSwaggerGen(o =>
            {
                o.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title       = "Dutch Exposure Notification API (inc. dev support)",
                    Version     = "v1",
                    Description = "This specification describes the interface between the Dutch exposure notification app and the backend service.\nTODO: Add signatures to manifest, riskcalculationparameters and appconfig",
                    Contact     = new OpenApiContact
                    {
                        Name = "Ministerie van Volksgezondheid Welzijn en Sport backend repository", //TODO looks wrong?
                        Url  = new Uri("https://github.com/minvws/nl-covid19-notification-app-backend"),
                    },
                    License = new OpenApiLicense
                    {
                        Name = "European Union Public License v. 1.2",
                        //TODO this should be https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
                        Url = new Uri("https://github.com/minvws/nl-covid19-notification-app-backend/blob/master/LICENSE.txt")
                    },
                });
                o.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "NL.Rijksoverheid.ExposureNotification.BackEnd.ServerStandAlone.xml"));
                o.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "NL.Rijksoverheid.ExposureNotification.BackEnd.Components.xml"));
            });
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            services.AddLogging();
            services.AddScoped <IJsonSerializer, StandardJsonSerializer>();
            services.AddControllers(options => { options.RespectBrowserAcceptHeader = true; });

            IIccPortalConfig iccPortalConfig = new IccPortalConfig(_Configuration, "IccPortalConfig");

            services.AddSingleton(iccPortalConfig);

            // Database Scoping
            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(_Configuration, "WorkFlow");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new WorkflowDbContext(builder.Build());
                result.BeginTransaction();
                return(result);
            });

            services.AddScoped <HttpPostAuthoriseCommand>();
            services.AddScoped <HttpPostLabVerifyCommand>();
            services.AddScoped <AuthorisationWriterCommand>();
            services.AddScoped <IUtcDateTimeProvider, StandardUtcDateTimeProvider>();
            services.AddScoped <IRandomNumberGenerator, RandomNumberGenerator>();
            services.AddScoped <JwtService>();
            services.AddScoped <LabVerificationAuthorisationCommand>();
            services.AddScoped <PollTokens>();
            services.AddScoped <HttpGetLogoutCommand>();
            services.AddScoped <HttpGetUserClaimCommand>();
            services.AddScoped <HttpGetAuthorisationRedirectCommand>();

            services.AddMvc(config =>
            {
                config.EnableEndpointRouting = false;
                var policy = new AuthorizationPolicyBuilder()
                             .AddAuthenticationSchemes(TheIdentityHubDefaults.AuthenticationScheme)
                             .RequireAuthenticatedUser()
                             .Build();
                config.Filters.Add(new AuthorizeFilter(policy));
                // .RequireClaim(ClaimTypes.Role) //TODO still needed or dead line?
            });

            services.AddCors();

            services.AddSwaggerGen(o =>
            {
                o.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title       = "Dutch Exposure Notification ICC API (inc. dev support)",
                    Version     = "v1",
                    Description = "This specification describes the interface between the Dutch exposure notification app backend, ICC Webportal and the ICC backend service.",
                    Contact     = new OpenApiContact
                    {
                        Name = "Ministerie van Volksgezondheid Welzijn en Sport backend repository", //TODO looks wrong?
                        Url  = new Uri("https://github.com/minvws/nl-covid19-notification-app-backend"),
                    },
                    License = new OpenApiLicense
                    {
                        Name = "European Union Public License v. 1.2",
                        //TODO this should be https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
                        Url = new Uri("https://github.com/minvws/nl-covid19-notification-app-backend/blob/master/LICENSE.txt")
                    },
                });
                o.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "NL.Rijksoverheid.ExposureNotification.BackEnd.Components.xml"));
                o.AddSecurityDefinition("Icc", new OpenApiSecurityScheme
                {
                    Description = "Icc Code Authentication",
                    Name        = "Authorization",
                    In          = ParameterLocation.Header,
                    Type        = SecuritySchemeType.ApiKey,
                    Scheme      = "IccAuthentication"
                });
                o.OperationFilter <SecurityRequirementsOperationFilter>();
            });

            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            // TODO: Make service for adding authentication + configuration model
            services
            .AddAuthentication(auth => {
                auth.DefaultChallengeScheme    = TheIdentityHubDefaults.AuthenticationScheme;
                auth.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                auth.DefaultSignInScheme       = CookieAuthenticationDefaults.AuthenticationScheme;
            })
            .AddCookie()
            .AddTheIdentityHubAuthentication(options =>
            {
                if (!string.IsNullOrWhiteSpace(iccPortalConfig.IdentityHubConfig.BaseUrl))
                {
                    options.TheIdentityHubUrl = new Uri(iccPortalConfig.IdentityHubConfig.BaseUrl);
                }

                //TODO if the Url is not set is there any sense to setting these?
                options.Tenant       = iccPortalConfig.IdentityHubConfig.Tenant;
                options.ClientId     = iccPortalConfig.IdentityHubConfig.ClientId;
                options.ClientSecret = iccPortalConfig.IdentityHubConfig.ClientSecret;
            });

            services.AddMvc(config =>
            {
                config.EnableEndpointRouting = false;
                var policy = new AuthorizationPolicyBuilder()
                             .AddAuthenticationSchemes(TheIdentityHubDefaults.AuthenticationScheme)
                             .RequireAuthenticatedUser()
                             .Build();
                config.Filters.Add(new AuthorizeFilter(policy));
                // .RequireClaim(ClaimTypes.Role)
            });

            services
            .AddAuthentication("jwt")
            .AddScheme <AuthenticationSchemeOptions, StandardJwtAuthenticationHandler>("jwt", null);
        }
예제 #26
0
        private static void Configure(IServiceCollection services, IConfigurationRoot configuration)
        {
            var _Configuration = configuration; //Temp hack before extension method.

            services.AddLogging();

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(configuration, "Content");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new ContentDbContext(builder.Build());
                return(result);
            });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(configuration, "PublishingJob");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new PublishingJobDbContext(builder.Build());
                return(result);
            });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(configuration, "Workflow");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new WorkflowDbContext(builder.Build());
                return(result);
            });

            services.AddSingleton <IConfiguration>(configuration);
            services.AddSingleton <IUtcDateTimeProvider, StandardUtcDateTimeProvider>();
            services.AddScoped(x =>
                               new ExposureKeySetBatchJobMk2(
                                   x.GetRequiredService <IGaenContentConfig>(),
                                   x.GetRequiredService <IExposureKeySetBuilder>(),
                                   x.GetRequiredService <WorkflowDbContext>(),
                                   x.GetRequiredService <PublishingJobDbContext>(),
                                   x.GetRequiredService <ContentDbContext>(),
                                   x.GetRequiredService <IUtcDateTimeProvider>(),
                                   x.GetRequiredService <IPublishingId>(),
                                   x.GetRequiredService <ILogger <ExposureKeySetBatchJobMk2> >()
                                   ));

            services.AddSingleton <IGaenContentConfig, StandardGaenContentConfig>();
            services.AddScoped <IExposureKeySetHeaderInfoConfig, ExposureKeySetHeaderInfoConfig>();
            services.AddScoped <IPublishingId, StandardPublishingIdFormatter>();

            if (_Configuration.GetValue("DevelopmentFlags:UseCertificatesFromResources", false))
            {
                if (_Configuration.GetValue("DevelopmentFlags:Azure", false))
                {
                    //AZURE
                    services.AddScoped <IExposureKeySetBuilder>(x =>
                                                                new ExposureKeySetBuilderV1(
                                                                    x.GetRequiredService <IExposureKeySetHeaderInfoConfig>(),
                                                                    new EcdSaSigner(new AzureResourceCertificateProvider(new StandardCertificateLocationConfig(_Configuration, "Certificates:GA"))),
                                                                    new CmsSigner(new AzureResourceCertificateProvider(new StandardCertificateLocationConfig(_Configuration, "Certificates:NL"))),
                                                                    x.GetRequiredService <IUtcDateTimeProvider>(), //TODO pass in time thru execute
                                                                    new GeneratedProtobufContentFormatter(),
                                                                    x.GetRequiredService <ILogger <ExposureKeySetBuilderV1> >()
                                                                    ));

                    services.AddScoped <IContentSigner>(x => new CmsSigner(new AzureResourceCertificateProvider(new StandardCertificateLocationConfig(_Configuration, "Certificates:NL"))));
                }
                else
                {
                    //UNIT TESTS, LOCAL DEBUG
                    services.AddScoped <IExposureKeySetBuilder>(x =>
                                                                new ExposureKeySetBuilderV1(
                                                                    x.GetRequiredService <IExposureKeySetHeaderInfoConfig>(),
                                                                    new EcdSaSigner(new LocalResourceCertificateProvider(new StandardCertificateLocationConfig(x.GetRequiredService <IConfiguration>(), "Certificates:GA"))),
                                                                    new CmsSigner(new LocalResourceCertificateProvider(new StandardCertificateLocationConfig(x.GetRequiredService <IConfiguration>(), "Certificates:NL"))),
                                                                    x.GetRequiredService <IUtcDateTimeProvider>(), //TODO pass in time thru execute
                                                                    new GeneratedProtobufContentFormatter(),
                                                                    x.GetRequiredService <ILogger <ExposureKeySetBuilderV1> >()
                                                                    ));

                    services.AddScoped <IContentSigner>(x => new CmsSigner(new LocalResourceCertificateProvider(new StandardCertificateLocationConfig(_Configuration, "Certificates:NL"))));
                }
            }
            else
            {
                //PROD
                services.AddScoped <IExposureKeySetBuilder>(x =>
                                                            new ExposureKeySetBuilderV1(
                                                                x.GetRequiredService <IExposureKeySetHeaderInfoConfig>(),
                                                                new EcdSaSigner(new X509CertificateProvider(new CertificateProviderConfig(x.GetRequiredService <IConfiguration>(), "Certificates:GA"), x.GetRequiredService <ILogger <X509CertificateProvider> >())),
                                                                new CmsSigner(new X509CertificateProvider(new CertificateProviderConfig(x.GetRequiredService <IConfiguration>(), "Certificates:NL"), x.GetRequiredService <ILogger <X509CertificateProvider> >())),
                                                                x.GetRequiredService <IUtcDateTimeProvider>(), //TODO pass in time thru execute
                                                                new GeneratedProtobufContentFormatter(),
                                                                x.GetRequiredService <ILogger <ExposureKeySetBuilderV1> >()
                                                                ));

                services.AddScoped <IContentSigner>(x => new CmsSigner(new X509CertificateProvider(new CertificateProviderConfig(x.GetRequiredService <IConfiguration>(), "Certificates:NL"), x.GetRequiredService <ILogger <X509CertificateProvider> >())));
            }
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services
            .AddControllers(options => { options.RespectBrowserAcceptHeader = true; })
            //Arming these options only makes them less tolerant of casing on Deserialization and DOES NOT for serialisation to camelCase.
            //.AddNewtonsoftJson(options =>
            //{
            //    options.UseCamelCasing(false); //NB this IS setting camel case - just not for dictionary element names
            //})
            ;

            //Same with this one.
            //services.AddMvc()
            //    .AddJsonOptions(options => options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase);

            services.AddControllers();

            services.AddSingleton <IUtcDateTimeProvider, StandardUtcDateTimeProvider>();
            services.AddSingleton <IGaenContentConfig, GaenContentConfig>();
            services.AddSingleton <IExposureKeySetBatchJobConfig, ExposureKeySetBatchJobConfig>();
            services.AddScoped <IPublishingId, StandardPublishingIdFormatter>();

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "Content");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new ExposureContentDbContext(builder.Build());
                result.BeginTransaction();
                return(result);
            });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "WorkFlow");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new WorkflowDbContext(builder.Build());
                result.BeginTransaction();
                return(result);
            });
            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "Icc");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new IccBackendContentDbContext(builder.Build());
                result.BeginTransaction();
                return(result);
            });

            //Just for the Batch Job
            //services.AddScoped<IEfDbConfig>(x => new StandardEfDbConfig(Configuration, "Job"));
            //services.AddScoped<IExposureKeySetHeaderInfoConfig, ExposureKeySetHeaderInfoConfig>();
            services.AddScoped <IContentSigner, FakeContentSigner>();
            services.AddSingleton <IGeanTekListValidationConfig, StandardGeanCommonWorkflowConfig>();
            services.AddSingleton <ITemporaryExposureKeyValidator, TemporaryExposureKeyValidator>();
            services.AddSingleton <ITemporaryExposureKeyValidatorConfig, TemporaryExposureKeyValidatorConfig>();
            services.AddScoped <IPublishingId, StandardPublishingIdFormatter>();


            services.AddScoped(x =>
                               new ExposureKeySetBatchJobMk2(
                                   x.GetService <IGaenContentConfig>(),
                                   x.GetService <IExposureKeySetBuilder>(),
                                   x.GetService <WorkflowDbContext>(),
                                   x.GetService <ExposureContentDbContext>(),
                                   x.GetService <IUtcDateTimeProvider>(),
                                   x.GetService <IPublishingId>()
                                   ));

            services.AddSingleton <IGaenContentConfig, GaenContentConfig>();
            services.AddScoped <IExposureKeySetBuilder>(x =>
                                                        new ExposureKeySetBuilderV1(
                                                            x.GetService <IExposureKeySetHeaderInfoConfig>(),
                                                            new EcdSaSigner(new ResourceCertificateProvider("FakeECDSA.p12")),
                                                            new CmsSigner(new ResourceCertificateProvider("FakeRSA.p12")),
                                                            x.GetService <IUtcDateTimeProvider>(), //TODO pass in time thru execute
                                                            new GeneratedProtobufContentFormatter()
                                                            ));

            services.AddScoped <IExposureKeySetHeaderInfoConfig, ExposureKeySetHeaderInfoConfig>();
            services.AddSingleton <ISignatureValidator>(new FakeSignatureValidator());

            services.AddScoped(x =>
                               new ExposureKeySetBuilderV1(
                                   x.GetService <ExposureKeySetHeaderInfoConfig>(),
                                   new FakeContentSigner(),
                                   new FakeContentSigner(),
                                   x.GetService <IUtcDateTimeProvider>(),
                                   new GeneratedProtobufContentFormatter()
                                   ));

            services.AddScoped <ManifestBuilder, ManifestBuilder>();
            services.AddScoped <GetActiveExposureKeySetsListCommand, GetActiveExposureKeySetsListCommand>();

            services.AddScoped <ExposureKeySetSafeReadCommand, ExposureKeySetSafeReadCommand>();
            services.AddScoped <SafeGetRiskCalculationConfigDbCommand, SafeGetRiskCalculationConfigDbCommand>();

            services.AddScoped <HttpPostRiskCalculationConfigCommand, HttpPostRiskCalculationConfigCommand>();
            services.AddScoped <RiskCalculationConfigValidator, RiskCalculationConfigValidator>();
            services.AddScoped <RiskCalculationConfigInsertDbCommand, RiskCalculationConfigInsertDbCommand>();

            services.AddScoped <HttpPostResourceBundleCommand, HttpPostResourceBundleCommand>();
            services.AddScoped <ResourceBundleInsertDbCommand, ResourceBundleInsertDbCommand>();
            services.AddScoped <ResourceBundleValidator, ResourceBundleValidator>();

            services.AddScoped <ProvisionDatabasesCommand, ProvisionDatabasesCommand>();
            services.AddScoped <ProvisionDatabasesCommandIcc, ProvisionDatabasesCommandIcc>();
            services.AddScoped <HttpPostGenerateExposureKeySetsCommand, HttpPostGenerateExposureKeySetsCommand>();
            //services.AddScoped<HttpGetCdnContentCommand<ManifestEntity>, HttpGetCdnContentCommand<ManifestEntity>>();

            services.AddScoped <HttpGetSignedCdnContentOnlyCommand <ExposureKeySetContentEntity>, HttpGetSignedCdnContentOnlyCommand <ExposureKeySetContentEntity> >();
            services.AddScoped <HttpGetCdnContentCommand <RiskCalculationContentEntity>, HttpGetCdnContentCommand <RiskCalculationContentEntity> >();
            services.AddScoped <HttpGetCdnContentCommand <ResourceBundleContentEntity>, HttpGetCdnContentCommand <ResourceBundleContentEntity> >();
            services.AddScoped <HttpGetCdnContentCommand <AppConfigContentEntity>, HttpGetCdnContentCommand <AppConfigContentEntity> >();

            services.AddScoped <DynamicManifestReader, DynamicManifestReader>();
            services.AddScoped <IReader <ExposureKeySetContentEntity>, SafeBinaryContentDbReader <ExposureKeySetContentEntity> >();
            services.AddScoped <IReader <ResourceBundleContentEntity>, SafeBinaryContentDbReader <ResourceBundleContentEntity> >();
            services.AddScoped <IReader <RiskCalculationContentEntity>, SafeBinaryContentDbReader <RiskCalculationContentEntity> >();
            services.AddScoped <IReader <AppConfigContentEntity>, SafeBinaryContentDbReader <AppConfigContentEntity> >();
            services.AddScoped <PurgeExpiredSecretsDbCommand, PurgeExpiredSecretsDbCommand>();

            services.AddScoped <HttpPostRegisterSecret, HttpPostRegisterSecret>();
            services.AddScoped <RandomNumberGenerator, RandomNumberGenerator>();
            services.AddScoped <ISecretConfig, StandardSecretConfig>();

            services.AddScoped <ISecretWriter, SecretWriter>();

            services.AddScoped <AuthorisationWriter, AuthorisationWriter>();

            services.AddScoped <HttpPostReleaseTeksCommand, HttpPostReleaseTeksCommand>();
            services.AddScoped <IReleaseTeksValidator, ReleaseTeksValidator>();

            services.AddScoped <ITekWriter, TekWriter>();

            services.AddScoped <HttpPostAppConfigCommand, HttpPostAppConfigCommand>();
            services.AddScoped <AppConfigInsertDbCommand, AppConfigInsertDbCommand>();
            services.AddScoped <AppConfigValidator, AppConfigValidator>();

            services.AddScoped <HttpPostAuthorise, HttpPostAuthorise>();
            services.AddScoped <IAuthorisationWriter, AuthorisationWriter>();

            services.AddScoped <IBasicAuthenticationConfig, BasicAuthenticationConfig>();
            services.AddBasicAuthentication();

            services.AddScoped <GetLatestContentCommand <ResourceBundleContentEntity>, GetLatestContentCommand <ResourceBundleContentEntity> >();
            services.AddScoped <GetLatestContentCommand <RiskCalculationContentEntity>, GetLatestContentCommand <RiskCalculationContentEntity> >();
            services.AddScoped <GetLatestContentCommand <AppConfigContentEntity>, GetLatestContentCommand <AppConfigContentEntity> >();

            services.AddScoped <IContentEntityFormatter, StandardContentEntityFormatter>();
            services.AddScoped <ZippedSignedContentFormatter, ZippedSignedContentFormatter>();

            services.AddScoped <HttpGetManifestBinaryContentCommand, HttpGetManifestBinaryContentCommand>();
            services.AddScoped <DynamicManifestReader, DynamicManifestReader>();
            services.AddScoped <HttpGetManifestSasCommand, HttpGetManifestSasCommand>();

            services.AddSwaggerGen(o =>
            {
                o.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title       = "Dutch Exposure Notification API (inc. dev support)",
                    Version     = "v1",
                    Description = "This specification describes the interface between the Dutch exposure notification app and the backend service.\nTODO: Add signatures to manifest, riskcalculationparameters and appconfig",
                    Contact     = new OpenApiContact
                    {
                        Name = "Ministerie van Volksgezondheid Welzijn en Sport backend repository", //TODO looks wrong?
                        Url  = new Uri("https://github.com/minvws/nl-covid19-notification-app-backend"),
                    },
                    License = new OpenApiLicense
                    {
                        Name = "European Union Public License v. 1.2",
                        //TODO this should be https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
                        Url = new Uri("https://github.com/minvws/nl-covid19-notification-app-backend/blob/master/LICENSE.txt")
                    },
                });
                o.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "NL.Rijksoverheid.ExposureNotification.BackEnd.ServerStandAlone.xml"));
                o.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "NL.Rijksoverheid.ExposureNotification.BackEnd.Components.xml"));


                o.AddSecurityDefinition("basic", new OpenApiSecurityScheme
                {
                    Name        = "Authorization",
                    Type        = SecuritySchemeType.Http,
                    Scheme      = "basic",
                    In          = ParameterLocation.Header,
                    Description = "Basic Authorization header."
                });
                o.AddSecurityRequirement(new OpenApiSecurityRequirement
                {
                    {
                        new OpenApiSecurityScheme
                        {
                            Reference = new OpenApiReference
                            {
                                Type = ReferenceType.SecurityScheme,
                                Id   = "basic"
                            }
                        },
                        new string[] {}
                    }
                });
            });
        }
        private static void Configure(IServiceCollection services, IConfigurationRoot configuration)
        {
            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(configuration, "Content");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new ContentDbContext(builder.Build());
                return(result);
            });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(configuration, "Workflow");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new WorkflowDbContext(builder.Build());
                return(result);
            });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(configuration, "Icc");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new IccBackendContentDbContext(builder.Build());
                return(result);
            });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(configuration, "PublishingJob");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new PublishingJobDbContext(builder.Build());
                return(result);
            });

            services.AddTransient <WorkflowDatabaseCreateCommand>();
            services.AddTransient <PublishingJobDatabaseCreateCommand>();
            services.AddTransient <IccDatabaseCreateCommand>();
            services.AddTransient <ContentDatabaseCreateCommand>();

            services.AddLogging();
            services.AddSingleton <IConfiguration>(configuration);
            services.AddTransient <IJsonSerializer, StandardJsonSerializer>();
            services.AddTransient <ProvisionDatabasesCommand>();
            services.AddSingleton <IUtcDateTimeProvider, StandardUtcDateTimeProvider>();
            services.AddSingleton <IGaenContentConfig, StandardGaenContentConfig>();
            services.AddTransient <IPublishingId, StandardPublishingIdFormatter>();
            services.AddTransient <ContentValidator>();
            services.AddTransient <ContentInsertDbCommand>();
            services.AddTransient <ZippedSignedContentFormatter>();

            if (configuration.GetValue("DevelopmentFlags:UseCertificatesFromResources", false))
            {
                if (configuration.GetValue("DevelopmentFlags:Azure", false))
                {
                    //AZURE
                    services.AddScoped <IContentSigner>(x => new CmsSigner(new AzureResourceCertificateProvider(new StandardCertificateLocationConfig(configuration, "Certificates:NL"))));
                }
                else
                {
                    //UNIT TESTS, LOCAL DEBUG
                    services.AddScoped <IContentSigner>(x => new CmsSigner(new LocalResourceCertificateProvider(new StandardCertificateLocationConfig(configuration, "Certificates:NL"))));
                }
            }
            else
            {
                services.AddScoped <IContentSigner>(x => new CmsSigner(new X509CertificateProvider(new CertificateProviderConfig(x.GetRequiredService <IConfiguration>(), "Certificates:NL"), x.GetRequiredService <ILogger <X509CertificateProvider> >())));
            }
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ComponentsContainerHelper.RegisterDefaultServices(services);

            services.AddControllers(options =>
            {
                options.RespectBrowserAcceptHeader = true;
            });

            services.AddSeriLog(Configuration);
            services.AddBasicAuthentication();

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "WorkFlow");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new WorkflowDbContext(builder.Build());
                return(result);
            });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "Content");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new ExposureContentDbContext(builder.Build());
                return(result);
            });

            services.AddSingleton <IUtcDateTimeProvider, StandardUtcDateTimeProvider>();

            services.AddScoped <HttpPostGenerateExposureKeySetsCommand, HttpPostGenerateExposureKeySetsCommand>();

            services.AddScoped(x =>
                               new ExposureKeySetBatchJobMk2(
                                   x.GetService <IGaenContentConfig>(),
                                   x.GetService <IExposureKeySetBuilder>(),
                                   x.GetService <WorkflowDbContext>(),
                                   x.GetService <ExposureContentDbContext>(),
                                   x.GetService <IUtcDateTimeProvider>(),
                                   x.GetService <IPublishingId>()
                                   ));

            services.AddSingleton <IGaenContentConfig, GaenContentConfig>();
            services.AddScoped <IExposureKeySetBuilder>(x =>
                                                        new ExposureKeySetBuilderV1(
                                                            x.GetService <IExposureKeySetHeaderInfoConfig>(),
                                                            new EcdSaSigner(new HsmCertificateProvider(new CertificateProviderConfig(x.GetService <IConfiguration>(), "ExposureKeySets:Signing:GA"))),
                                                            new CmsSigner(new HsmCertificateProvider(new CertificateProviderConfig(x.GetService <IConfiguration>(), "ExposureKeySets:Signing:NL"))),
                                                            x.GetService <IUtcDateTimeProvider>(), //TODO pass in time thru execute
                                                            new GeneratedProtobufContentFormatter()
                                                            ));
            services.AddScoped <IExposureKeySetHeaderInfoConfig, ExposureKeySetHeaderInfoConfig>();
            services.AddScoped <IPublishingId, StandardPublishingIdFormatter>();

            services.AddSwaggerGen(o =>
            {
                o.SwaggerDoc("v1", new OpenApiInfo {
                    Title = Title, Version = "v1"
                });

                o.AddSecurityDefinition("basic", new OpenApiSecurityScheme
                {
                    Name        = "Authorization",
                    Type        = SecuritySchemeType.Http,
                    Scheme      = "basic",
                    In          = ParameterLocation.Header,
                    Description = "Basic Authorization header using the Bearer scheme."
                });

                o.AddSecurityRequirement(new OpenApiSecurityRequirement
                {
                    {
                        new OpenApiSecurityScheme
                        {
                            Reference = new OpenApiReference
                            {
                                Type = ReferenceType.SecurityScheme,
                                Id   = "basic"
                            }
                        },
                        new string[] {}
                    }
                });
            });
        }