Browse Source

Merge pull request #10359 from abpframework/maliming/DataProtection

Set same application name  for `DataProtection`.
pull/10373/head
Halil İbrahim Kalkan 5 years ago
committed by GitHub
parent
commit
7cc616a097
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyProjectNameBlazorModule.cs
  2. 9
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs
  3. 5
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs
  4. 9
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs
  5. 5
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs
  6. 5
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs
  7. 9
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostModule.cs

17
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyProjectNameBlazorModule.cs

@ -98,7 +98,7 @@ namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered
ConfigureBlazorise(context); ConfigureBlazorise(context);
ConfigureRouter(context); ConfigureRouter(context);
ConfigureMenu(configuration); ConfigureMenu(configuration);
ConfigureRedis(context, configuration, hostingEnvironment); ConfigureDataProtection(context, configuration, hostingEnvironment);
ConfigureSwaggerServices(context.Services); ConfigureSwaggerServices(context.Services);
} }
@ -109,7 +109,7 @@ namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
}); });
} }
private void ConfigureCache() private void ConfigureCache()
{ {
Configure<AbpDistributedCacheOptions>(options => Configure<AbpDistributedCacheOptions>(options =>
@ -143,7 +143,7 @@ namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered
); );
}); });
} }
private void ConfigureMultiTenancy() private void ConfigureMultiTenancy()
{ {
Configure<AbpMultiTenancyOptions>(options => Configure<AbpMultiTenancyOptions>(options =>
@ -253,7 +253,7 @@ namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered
{ {
options.MenuContributors.Add(new MyProjectNameMenuContributor(configuration)); options.MenuContributors.Add(new MyProjectNameMenuContributor(configuration));
}); });
Configure<AbpToolbarOptions>(options => Configure<AbpToolbarOptions>(options =>
{ {
options.Contributors.Add(new MyProjectNameToolbarContributor()); options.Contributors.Add(new MyProjectNameToolbarContributor());
@ -275,7 +275,7 @@ namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered
options.AddMaps<MyProjectNameBlazorModule>(); options.AddMaps<MyProjectNameBlazorModule>();
}); });
} }
private void ConfigureSwaggerServices(IServiceCollection services) private void ConfigureSwaggerServices(IServiceCollection services)
{ {
services.AddAbpSwaggerGen( services.AddAbpSwaggerGen(
@ -288,17 +288,16 @@ namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered
); );
} }
private void ConfigureRedis( private void ConfigureDataProtection(
ServiceConfigurationContext context, ServiceConfigurationContext context,
IConfiguration configuration, IConfiguration configuration,
IWebHostEnvironment hostingEnvironment) IWebHostEnvironment hostingEnvironment)
{ {
var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName");
if (!hostingEnvironment.IsDevelopment()) if (!hostingEnvironment.IsDevelopment())
{ {
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
context.Services dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys");
.AddDataProtection()
.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys");
} }
} }

9
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs

@ -51,7 +51,7 @@ namespace MyCompanyName.MyProjectName
ConfigureLocalization(); ConfigureLocalization();
ConfigureCache(configuration); ConfigureCache(configuration);
ConfigureVirtualFileSystem(context); ConfigureVirtualFileSystem(context);
ConfigureRedis(context, configuration, hostingEnvironment); ConfigureDataProtection(context, configuration, hostingEnvironment);
ConfigureCors(context, configuration); ConfigureCors(context, configuration);
ConfigureSwaggerServices(context, configuration); ConfigureSwaggerServices(context, configuration);
} }
@ -145,17 +145,16 @@ namespace MyCompanyName.MyProjectName
}); });
} }
private void ConfigureRedis( private void ConfigureDataProtection(
ServiceConfigurationContext context, ServiceConfigurationContext context,
IConfiguration configuration, IConfiguration configuration,
IWebHostEnvironment hostingEnvironment) IWebHostEnvironment hostingEnvironment)
{ {
var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName");
if (!hostingEnvironment.IsDevelopment()) if (!hostingEnvironment.IsDevelopment())
{ {
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
context.Services dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys");
.AddDataProtection()
.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys");
} }
} }

5
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs

@ -133,12 +133,11 @@ namespace MyCompanyName.MyProjectName
options.KeyPrefix = "MyProjectName:"; options.KeyPrefix = "MyProjectName:";
}); });
var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName");
if (!hostingEnvironment.IsDevelopment()) if (!hostingEnvironment.IsDevelopment())
{ {
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
context.Services dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys");
.AddDataProtection()
.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys");
} }
context.Services.AddCors(options => context.Services.AddCors(options =>

9
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs

@ -81,7 +81,7 @@ namespace MyCompanyName.MyProjectName.Web
ConfigureBundles(); ConfigureBundles();
ConfigureCache(); ConfigureCache();
ConfigureRedis(context, configuration, hostingEnvironment); ConfigureDataProtection(context, configuration, hostingEnvironment);
ConfigureUrls(configuration); ConfigureUrls(configuration);
ConfigureAuthentication(context, configuration); ConfigureAuthentication(context, configuration);
ConfigureAutoMapper(); ConfigureAutoMapper();
@ -214,17 +214,16 @@ namespace MyCompanyName.MyProjectName.Web
); );
} }
private void ConfigureRedis( private void ConfigureDataProtection(
ServiceConfigurationContext context, ServiceConfigurationContext context,
IConfiguration configuration, IConfiguration configuration,
IWebHostEnvironment hostingEnvironment) IWebHostEnvironment hostingEnvironment)
{ {
var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName");
if (!hostingEnvironment.IsDevelopment()) if (!hostingEnvironment.IsDevelopment())
{ {
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
context.Services dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys");
.AddDataProtection()
.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys");
} }
} }

5
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs

@ -126,12 +126,11 @@ namespace MyCompanyName.MyProjectName
options.KeyPrefix = "MyProjectName:"; options.KeyPrefix = "MyProjectName:";
}); });
var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName");
if (!hostingEnvironment.IsDevelopment()) if (!hostingEnvironment.IsDevelopment())
{ {
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
context.Services dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys");
.AddDataProtection()
.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys");
} }
context.Services.AddCors(options => context.Services.AddCors(options =>

5
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs

@ -153,12 +153,11 @@ namespace MyCompanyName.MyProjectName
options.IsEnabled = MultiTenancyConsts.IsEnabled; options.IsEnabled = MultiTenancyConsts.IsEnabled;
}); });
var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName");
if (!hostingEnvironment.IsDevelopment()) if (!hostingEnvironment.IsDevelopment())
{ {
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
context.Services dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys");
.AddDataProtection()
.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys");
} }
context.Services.AddCors(options => context.Services.AddCors(options =>

9
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostModule.cs

@ -100,7 +100,7 @@ namespace MyCompanyName.MyProjectName
ConfigureVirtualFileSystem(hostingEnvironment); ConfigureVirtualFileSystem(hostingEnvironment);
ConfigureSwaggerServices(context.Services); ConfigureSwaggerServices(context.Services);
ConfigureMultiTenancy(); ConfigureMultiTenancy();
ConfigureRedis(context, configuration, hostingEnvironment); ConfigureDataProtection(context, configuration, hostingEnvironment);
} }
private void ConfigureMenu(IConfiguration configuration) private void ConfigureMenu(IConfiguration configuration)
@ -207,17 +207,16 @@ namespace MyCompanyName.MyProjectName
); );
} }
private void ConfigureRedis( private void ConfigureDataProtection(
ServiceConfigurationContext context, ServiceConfigurationContext context,
IConfiguration configuration, IConfiguration configuration,
IWebHostEnvironment hostingEnvironment) IWebHostEnvironment hostingEnvironment)
{ {
var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName");
if (!hostingEnvironment.IsDevelopment()) if (!hostingEnvironment.IsDevelopment())
{ {
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
context.Services dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys");
.AddDataProtection()
.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys");
} }
} }

Loading…
Cancel
Save