public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); var env = context.GetEnvironment(); //if (env.IsDevelopment()) //{ app.UseDeveloperExceptionPage(); //} var provider = new FileExtensionContentTypeProvider(); provider.Mappings[".less"] = "text/css"; app.UseStaticFiles(new StaticFileOptions() { ContentTypeProvider = provider }); #region Nlog LogManager.Configuration.Variables["connectionString"] = context.GetConfiguration()["ConnectionStrings:Default"]; LogManager.Configuration.Variables["nlogDbProvider"] = context.GetConfiguration()["ConnectionStrings:Default"]; #endregion app.UseStaticHttpContext(); app.UseCookiePolicy(); app.UseAuthentication(); app.UseAuthorization(); app.UseRouting(); app.UseMvcWithDefaultRouteAndArea(); }
public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); var env = context.GetEnvironment(); var configuration = context.GetConfiguration(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseAbpRequestLocalization(); app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); app.UseCors(DefaultCorsPolicyName); app.UseAuthentication(); app.UseAuthorization(); if (bool.Parse(configuration["MultiTenancy"])) { app.UseMultiTenancy(); } app.UseAuditing(); app.UseConfiguredEndpoints(); }
public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); var configuration = context.GetConfiguration(); // http调用链 app.UseCorrelationId(); // 虚拟文件系统 app.UseVirtualFiles(); //路由 app.UseRouting(); // 认证 app.UseAuthentication(); app.UseAbpClaimsMap(); // 多租户 // app.UseMultiTenancy(); // 本地化 app.UseAbpRequestLocalization(); // Swagger app.UseSwagger(); // Swagger可视化界面 app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support ApiGateway API"); }); // 审计日志 app.UseAuditing(); // 路由 app.UseConfiguredEndpoints(); if (configuration.GetSection("ApiGateway:SeedInitScript").Get <bool>()) { SeedData(context); } }
public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); var env = context.GetEnvironment(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseAbpRequestLocalization(); if (!env.IsDevelopment()) { app.UseErrorPage(); } app.UseCorrelationId(); app.UseRouting(); app.UseCors(DefaultCorsPolicyName); app.UseSwagger(); app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "Practice API"); var configuration = context.GetConfiguration(); options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); }); //app.UseAuditing(); app.UseAbpSerilogEnrichers(); app.UseConfiguredEndpoints(); }
/// <summary> /// /// </summary> /// <param name="context"></param> public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); var env = context.GetEnvironment(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseAbpRequestLocalization(); app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); app.UseCors(DefaultCorsPolicyName); app.UseAuthentication(); app.UseAuthorization(); app.UseHealthChecks("/health"); app.UseSwagger(); app.UseAbpSwaggerUI(options => { options.DocumentTitle = "IngosConfiguration API"; // Display latest api version by default // var provider = context.ServiceProvider.GetRequiredService <IApiVersionDescriptionProvider>(); var apiVersionList = provider.ApiVersionDescriptions .Select(i => $"v{i.ApiVersion.MajorVersion}") .Distinct().Reverse(); foreach (var apiVersion in apiVersionList) { options.SwaggerEndpoint($"/swagger/{apiVersion}/swagger.json", $"IngosConfiguration API {apiVersion?.ToUpperInvariant()}"); } var configuration = context.GetConfiguration(); options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); }); app.UseAuditing(); app.UseAbpSerilogEnrichers(); app.UseUnitOfWork(); app.UseConfiguredEndpoints(); }
public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); var env = context.GetEnvironment(); var configuration = context.GetConfiguration(); // 确保 Abp.Mailing.Smtp.Password 的 setting 值被加密 var settingManager = context.ServiceProvider.GetService <SettingManager>(); const string smtpPasswordName = EmailSettingNames.Smtp.Password; /* 需要加密的内容不能放在 appsettings.json 的 Settings 下面 * 因为在加密过程中会依次查询该 SettingProvider 次序之前(优先级更低)的设置项是否存在该字段的值并进行比较 * 当在 GlobalProvider 设置值,程序会在 ConfigurationProvider 发现该字段的未加密内容 * 由于 appsettings.json 中保存的是未加密的值,所以进行解密操作时会报错 */ var password = configuration["AuthServer:EmailPassword"]; settingManager.SetGlobalAsync(smtpPasswordName, password); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } // 程序运行在 http 时会设置 Cookie 的 SameSite=None // 在 Chrome 这类浏览器上进行登录操作时无法将身份认证的 Cookie 保存到浏览器,导致登录不成功 app.UseCookiePolicy(new CookiePolicyOptions { MinimumSameSitePolicy = SameSiteMode.Lax }); app.UseAbpRequestLocalization(); app.UseCorrelationId(); app.UseStaticFiles(); app.UseRouting(); app.UseCors(DefaultCorsPolicyName); app.UseAuthentication(); app.UseIdentityServer(); app.UseAuthorization(); if (bool.Parse(configuration["MultiTenancy"])) { app.UseMultiTenancy(); } app.UseAuditing(); app.UseConfiguredEndpoints(); }
public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); var env = context.GetEnvironment(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseErrorPage(); app.UseHsts(); } #if DEBUG app.UseMiniProfiler(); #endif app.UseHttpsRedirection(); app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); app.UseCors(CorsExtensions.DefaultCorsPolicyName); //app.UseCors(DefaultCorsPolicyName); app.UseAuthentication(); if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); } app.UseJhRequestLocalization(); //app.UseAbpRequestLocalization(); app.UseAuthorization(); #if DEBUG app.UseJhSwagger(context.GetConfiguration(), this.GetType()); #endif //app.UseSwagger(); //app.UseAbpSwaggerUI(options => //{ // options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API"); // var configuration = context.GetConfiguration(); // options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); // options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); //}); app.UseAuditing(); app.UseAbpSerilogEnrichers(); app.UseConfiguredEndpoints(); //SeedData(context); }
public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); var env = context.GetEnvironment(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseAbpRequestLocalization(); app.UseAbpSecurityHeaders(); if (!env.IsDevelopment()) { app.UseErrorPage(); } app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); app.UseCors(DefaultCorsPolicyName); app.UseAuthentication(); if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); } app.UseAuthorization(); app.UseSwagger(); app.UseAbpSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API"); var configuration = context.GetConfiguration(); options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); options.OAuthScopes("MyProjectName"); }); app.UseAuditing(); app.UseAbpSerilogEnrichers(); app.UseUnitOfWork(); app.UseConfiguredEndpoints(); }
public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); var env = context.GetEnvironment(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseAbpRequestLocalization(); if (!env.IsDevelopment()) { app.UseErrorPage(); } app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); if (Convert.ToBoolean(context.GetConfiguration()["AppMetrics:Enabled"])) { app.UseAppMetricsMiddleware(); } app.UseCors(DefaultCorsPolicyName); app.UseAuthentication(); app.UseJwtTokenMiddleware(); if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); } // https://github.com/abpframework/abp/blob/dev/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerDomainModule.cs app.UseIdentityServer(); app.UseAuthorization(); app.UseSwagger(); app.UseAbpSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "SSO API"); }); app.UseAuditing(); app.UseAbpSerilogEnrichers(); app.UseConfiguredEndpoints(); }
public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); var configuration = context.GetConfiguration(); app.UseAbpRequestLocalization(); app.UseCorrelationId(); app.UseStaticFiles(); app.UseRouting(); if (bool.Parse(configuration["MultiTenancy"])) { app.UseMultiTenancy(); } app.UseAuthentication(); app.UseAuthorization(); app.UseSwagger(); app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "J3space Guard API"); options.OAuthConfigObject = new OAuthConfigObject { ClientId = configuration["AuthServer:ClientId"], ClientSecret = configuration["AuthServer:ClientSecret"], AppName = configuration["AuthServer:Audience"] }; }); app.UseCors(DefaultCorsPolicyName); app.MapWhen( // TODO: 考虑扩展性 ctx => ctx.Request.Path.ToString().StartsWith("/api/blogging/") || ctx.Request.Path.ToString().StartsWith("/api/identity/") || ctx.Request.Path.ToString().StartsWith("/api/ids/") || ctx.Request.Path.ToString().StartsWith("/api/multi-tenancy/"), app2 => { app2.UseOcelot().Wait(); } ); app.UseConfiguredEndpoints(); }
public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); var env = context.GetConfiguration(); app.UseAuthentication(); app.UseJwtTokenMiddleware(); app.UseAuditing(); app.UseIdentityServer(); app.UseRouting(); app.UseCors(env["DefaultCors:DefaultCorsPolicyName"]); app.UseMultiTenancy(); app.UseMvcWithDefaultRouteAndArea(); app.UseSwagger(); app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "version 0.1"); }); }
public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); var env = context.GetEnvironment(); var configuration = context.GetConfiguration(); if (env.EnvironmentName == "Development" || env.EnvironmentName == "Docker") { app.UseSwaggerService(); } app.UseCors("CorsPolicy"); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseConfiguredEndpoints(); app.ApplyMigrations(configuration); }
public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); if (!context.GetEnvironment().IsDevelopment()) { app.UseHsts(); } app.UseHttpsRedirection(); app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); app.UseCors(DefaultCorsPolicyName); app.UseAuthentication(); if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); } app.UseAbpRequestLocalization(); app.UseAuthorization(); app.UseSwagger(); app.UseAbpSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "OrganizationSetupService API"); var configuration = context.GetConfiguration(); options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); }); app.UseAuditing(); app.UseAbpSerilogEnrichers(); app.UseConfiguredEndpoints(); SeedData(context); }
public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); var env = context.GetEnvironment(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); } app.UseStaticFiles(); app.UseRouting(); app.UseMvcWithDefaultRouteAndArea(); var configuration = context.GetConfiguration(); ExceptionlessClient.Default.Configuration.ApiKey = configuration.GetSection("Exceptionless:ApiKey").Value; //自己搭建的 Exceptionless 则配置对应的url // ExceptionlessClient.Default.Configuration.ServerUrl = configuration.GetSection("Exceptionless:ServerUrl").Value; app.UseExceptionless(); }
public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); var configuration = context.GetConfiguration(); app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); app.UseCors(DefaultCorsPolicyName); app.UseAuthentication(); app.UseAbpClaimsMap(); if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); } app.UseAbpRequestLocalization(); if (configuration["UseSwagger"] == "true") { app.UseSwagger(); app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "Business Service API"); }); } app.UseAuditing(); app.UseAbpSerilogEnrichers(); app.UseConfiguredEndpoints(); app.UseHangfireServer(); app.UseHangfireDashboard(options: new DashboardOptions { Authorization = new[] { new BasicAuthAuthorizationFilter(new BasicAuthAuthorizationFilterOptions { RequireSsl = false, SslRedirect = false, LoginCaseSensitive = true, Users = new [] { new BasicAuthAuthorizationUser { Login = configuration["Hangfire:Login"], PasswordClear = configuration["Hangfire:Password"] } } }) }, DashboardTitle = "任务调度中心" }); AsyncHelper.RunSync(async() => { using (var scope = context.ServiceProvider.CreateScope()) { await scope.ServiceProvider .GetRequiredService <IDataSeeder>() .SeedAsync(); } }); }