Ejemplo n.º 1
0
        public override void ConfigureServices(IServiceCollection services)
        {
            var authAppSettings     = Config.GetSectionAppSettings <AuthAppSettings>(AppSettingsConstants.Auth);
            var keyVaultAppSettings = Config.GetSectionAppSettings <KeyVaultAppSettings>(AppSettingsConstants.KeyVault);
            var swaggerAppSettings  = Config.GetSectionAppSettings <SwaggerAppSettings>(AppSettingsConstants.Swagger);

            var authenticationExtensionConfig = new AuthenticationExtensionConfig(Env,
                                                                                  ApiResourcesConstants.RivaIdentityApiResource.Name, authAppSettings.Authority,
                                                                                  AuthenticationExtension.JwtBearerAuthenticationScheme, keyVaultAppSettings.Name,
                                                                                  keyVaultAppSettings.SigningCredentialCertificateName);
            var authorizationExtensionConfig = new AuthorizationExtensionConfig(
                ApiResourcesConstants.RivaIdentityApiResource.Name, ResourceOwnerPolicy.CreateResourceOwnerPolicy());
            var swaggerExtensionConfig = new SwaggerExtensionConfig(ApiResourcesConstants.RivaIdentityApiResource.Name, swaggerAppSettings.IdentityUrl);
            var webApiExtensionConfig  = new WebApiExtensionConfig(Env, typeof(Startup).GetTypeInfo().Assembly,
                                                                   authorizationExtensionConfig, authenticationExtensionConfig, swaggerExtensionConfig,
                                                                   typeof(Startup).Assembly, typeof(AccountProfile).Assembly);

            services
            .AddWebApiForIntegrationTest(webApiExtensionConfig)
            .AddAuthorizationHandlers()
            .AddHealthChecks(Config)
            .AddAppSettings(Config)
            .AddIntegrationEventBus(Config.GetSectionAppSettings <ConnectionStringsAppSettings>(AppSettingsConstants.ConnectionStrings).CentralServiceBusConnectionString,
                                    Config.GetSectionAppSettings <CentralServiceBusAppSettings>(AppSettingsConstants.CentralServiceBus).SubscriptionName)
            .AddDependencies()
            .AddDbContext <RivaIdentityDbContext>(SqlServerConfigurator.Configure(services, Config, Env))
            .AddDomainEventsStore <RivaIdentityDbContext>()
            .AddHttpContextAccessor();
        }
Ejemplo n.º 2
0
        public static IServiceCollection AddWebApi(this IServiceCollection services, IConfiguration config, IWebHostEnvironment env)
        {
            var authAppSettings     = config.GetSectionAppSettings <AuthAppSettings>(AppSettingsConstants.Auth);
            var keyVaultAppSettings = config.GetSectionAppSettings <KeyVaultAppSettings>(AppSettingsConstants.KeyVault);
            var swaggerAppSettings  = config.GetSectionAppSettings <SwaggerAppSettings>(AppSettingsConstants.Swagger);

            var authenticationExtensionConfig = new AuthenticationExtensionConfig(env,
                                                                                  ApiResourcesConstants.RivaUsersApiResource.Name, authAppSettings.Authority,
                                                                                  AuthenticationExtension.JwtBearerAuthenticationScheme, keyVaultAppSettings.Name,
                                                                                  keyVaultAppSettings.SigningCredentialCertificateName);
            var authorizationExtensionConfig = new AuthorizationExtensionConfig(
                ApiResourcesConstants.RivaUsersApiResource.Name, ResourceOwnerPolicy.CreateResourceOwnerPolicy());
            var swaggerExtensionConfig = new SwaggerExtensionConfig(ApiResourcesConstants.RivaUsersApiResource.Name, swaggerAppSettings.IdentityUrl);
            var webApiExtensionConfig  = new WebApiExtensionConfig(env, typeof(Startup).GetTypeInfo().Assembly,
                                                                   authorizationExtensionConfig, authenticationExtensionConfig, swaggerExtensionConfig,
                                                                   typeof(Startup).Assembly, typeof(UserProfile).Assembly);

            return(services.AddWebApi(webApiExtensionConfig));
        }