From 5f4851262f02fa5f6b5f60545a45ab818c11ae3a Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Thu, 14 Feb 2019 12:06:48 +0300 Subject: [PATCH] Use redis cache for data protection --- .../AuthServer.Host/AuthServer.Host.csproj | 9 +++++++++ .../AuthServer.Host/AuthServerHostModule.cs | 6 ++++++ .../BackendAdminApp.Host/BackendAdminApp.Host.csproj | 9 +++++++++ .../BackendAdminAppHostModule.cs | 6 ++++++ .../PublicWebSite.Host/PublicWebSite.Host.csproj | 9 +++++++++ .../PublicWebSite.Host/PublicWebSiteHostModule.cs | 6 ++++++ .../BackendAdminAppGateway.Host.csproj | 9 +++++++++ .../BackendAdminAppGatewayHostModule.cs | 6 ++++++ .../InternalGateway.Host/InternalGateway.Host.csproj | 9 +++++++++ .../InternalGatewayHostModule.cs | 6 ++++++ .../PublicWebSiteGateway.Host.csproj | 9 +++++++++ .../PublicWebSiteGatewayHostModule.cs | 6 ++++++ .../BloggingService.Host/BloggingService.Host.csproj | 9 +++++++++ .../BloggingServiceHostModule.cs | 6 ++++++ .../IdentityService.Host/IdentityService.Host.csproj | 9 +++++++++ .../IdentityServiceHostModule.cs | 6 ++++++ .../ProductService.Host/ProductService.Host.csproj | 12 ++++++++---- .../ProductService.Host/ProductServiceHostModule.cs | 6 ++++++ 18 files changed, 134 insertions(+), 4 deletions(-) diff --git a/samples/MicroserviceDemo/applications/AuthServer.Host/AuthServer.Host.csproj b/samples/MicroserviceDemo/applications/AuthServer.Host/AuthServer.Host.csproj index 4f10fd61b9..89752802a7 100644 --- a/samples/MicroserviceDemo/applications/AuthServer.Host/AuthServer.Host.csproj +++ b/samples/MicroserviceDemo/applications/AuthServer.Host/AuthServer.Host.csproj @@ -17,6 +17,7 @@ + @@ -40,4 +41,12 @@ + + + + signed + + + + diff --git a/samples/MicroserviceDemo/applications/AuthServer.Host/AuthServerHostModule.cs b/samples/MicroserviceDemo/applications/AuthServer.Host/AuthServerHostModule.cs index bc0d0b825d..d147a49254 100644 --- a/samples/MicroserviceDemo/applications/AuthServer.Host/AuthServerHostModule.cs +++ b/samples/MicroserviceDemo/applications/AuthServer.Host/AuthServerHostModule.cs @@ -1,6 +1,8 @@ using AuthServer.Host.EntityFrameworkCore; using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; using Microsoft.Extensions.DependencyInjection; +using StackExchange.Redis; using Volo.Abp; using Volo.Abp.Account.Web; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic; @@ -67,6 +69,10 @@ namespace AuthServer.Host options.IsEnabledForGetRequests = true; options.ApplicationName = "AuthServer"; }); + + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + context.Services.AddDataProtection() + .PersistKeysToStackExchangeRedis(redis, "MsDemo-DataProtection-Keys"); } public override void OnApplicationInitialization(ApplicationInitializationContext context) diff --git a/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminApp.Host.csproj b/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminApp.Host.csproj index 01bc6634d5..8da540107a 100644 --- a/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminApp.Host.csproj +++ b/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminApp.Host.csproj @@ -19,6 +19,7 @@ + @@ -42,4 +43,12 @@ + + + + signed + + + + diff --git a/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminAppHostModule.cs b/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminAppHostModule.cs index 5969d69370..0bb625414a 100644 --- a/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminAppHostModule.cs +++ b/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminAppHostModule.cs @@ -1,9 +1,11 @@ using System; using Microsoft.AspNetCore.Authentication.OAuth.Claims; using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; using Microsoft.Extensions.DependencyInjection; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using ProductManagement; +using StackExchange.Redis; using Swashbuckle.AspNetCore.Swagger; using Volo.Abp; using Volo.Abp.AspNetCore.Authentication.OAuth; @@ -83,6 +85,10 @@ namespace BackendAdminApp.Host { options.Configuration = configuration["Redis:Configuration"]; }); + + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + context.Services.AddDataProtection() + .PersistKeysToStackExchangeRedis(redis, "MsDemo-DataProtection-Keys"); } public override void OnApplicationInitialization(ApplicationInitializationContext context) diff --git a/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSite.Host.csproj b/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSite.Host.csproj index 1585146a68..169b3d9e8d 100644 --- a/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSite.Host.csproj +++ b/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSite.Host.csproj @@ -18,6 +18,7 @@ + @@ -38,4 +39,12 @@ + + + + signed + + + + diff --git a/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs b/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs index 3591fc018d..c4f565dd5d 100644 --- a/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs +++ b/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs @@ -1,9 +1,11 @@ using System; using Microsoft.AspNetCore.Authentication.OAuth.Claims; using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; using Microsoft.Extensions.DependencyInjection; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using ProductManagement; +using StackExchange.Redis; using Volo.Abp; using Volo.Abp.AspNetCore.Authentication.OAuth; using Volo.Abp.AspNetCore.Mvc.Client; @@ -75,6 +77,10 @@ namespace PublicWebSite.Host { options.Configuration = configuration["Redis:Configuration"]; }); + + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + context.Services.AddDataProtection() + .PersistKeysToStackExchangeRedis(redis, "MsDemo-DataProtection-Keys"); } public override void OnApplicationInitialization(ApplicationInitializationContext context) diff --git a/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGateway.Host.csproj b/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGateway.Host.csproj index 1ec9405f2a..abaca0567b 100644 --- a/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGateway.Host.csproj +++ b/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGateway.Host.csproj @@ -20,6 +20,7 @@ + @@ -51,4 +52,12 @@ + + + + signed + + + + diff --git a/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGatewayHostModule.cs b/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGatewayHostModule.cs index ddc484b2da..660419662c 100644 --- a/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGatewayHostModule.cs +++ b/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGatewayHostModule.cs @@ -1,8 +1,10 @@ using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; using Microsoft.Extensions.DependencyInjection; using Ocelot.DependencyInjection; using Ocelot.Middleware; using ProductManagement; +using StackExchange.Redis; using Swashbuckle.AspNetCore.Swagger; using Volo.Abp; using Volo.Abp.Autofac; @@ -77,6 +79,10 @@ namespace BackendAdminAppGateway.Host { options.Configuration = configuration["Redis:Configuration"]; }); + + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + context.Services.AddDataProtection() + .PersistKeysToStackExchangeRedis(redis, "MsDemo-DataProtection-Keys"); } public override void OnApplicationInitialization(ApplicationInitializationContext context) diff --git a/samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGateway.Host.csproj b/samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGateway.Host.csproj index 8b56b69df7..0428736a75 100644 --- a/samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGateway.Host.csproj +++ b/samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGateway.Host.csproj @@ -20,6 +20,7 @@ + @@ -44,5 +45,13 @@ + + + + signed + + + + diff --git a/samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGatewayHostModule.cs b/samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGatewayHostModule.cs index 68c98a26a2..a418aabf79 100644 --- a/samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGatewayHostModule.cs +++ b/samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGatewayHostModule.cs @@ -1,8 +1,10 @@ using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; using Microsoft.Extensions.DependencyInjection; using Ocelot.DependencyInjection; using Ocelot.Middleware; using ProductManagement; +using StackExchange.Redis; using Swashbuckle.AspNetCore.Swagger; using Volo.Abp; using Volo.Abp.Autofac; @@ -64,6 +66,10 @@ namespace InternalGateway.Host { options.Configuration = configuration["Redis:Configuration"]; }); + + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + context.Services.AddDataProtection() + .PersistKeysToStackExchangeRedis(redis, "MsDemo-DataProtection-Keys"); } public override void OnApplicationInitialization(ApplicationInitializationContext context) diff --git a/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/PublicWebSiteGateway.Host.csproj b/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/PublicWebSiteGateway.Host.csproj index 6cddd67e53..cd41412f26 100644 --- a/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/PublicWebSiteGateway.Host.csproj +++ b/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/PublicWebSiteGateway.Host.csproj @@ -20,6 +20,7 @@ + @@ -44,4 +45,12 @@ + + + + signed + + + + \ No newline at end of file diff --git a/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/PublicWebSiteGatewayHostModule.cs b/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/PublicWebSiteGatewayHostModule.cs index 36b52cc1e3..88e74045d0 100644 --- a/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/PublicWebSiteGatewayHostModule.cs +++ b/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/PublicWebSiteGatewayHostModule.cs @@ -1,8 +1,10 @@ using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; using Microsoft.Extensions.DependencyInjection; using Ocelot.DependencyInjection; using Ocelot.Middleware; using ProductManagement; +using StackExchange.Redis; using Swashbuckle.AspNetCore.Swagger; using Volo.Abp; using Volo.Abp.Autofac; @@ -64,6 +66,10 @@ namespace PublicWebSiteGateway.Host { options.Configuration = configuration["Redis:Configuration"]; }); + + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + context.Services.AddDataProtection() + .PersistKeysToStackExchangeRedis(redis, "MsDemo-DataProtection-Keys"); } public override void OnApplicationInitialization(ApplicationInitializationContext context) diff --git a/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingService.Host.csproj b/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingService.Host.csproj index 10b797c0f4..5d3dc6cddb 100644 --- a/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingService.Host.csproj +++ b/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingService.Host.csproj @@ -19,6 +19,7 @@ + @@ -43,4 +44,12 @@ + + + + signed + + + + diff --git a/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs b/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs index 1ae68cfd55..cd4fec848f 100644 --- a/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs +++ b/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs @@ -1,7 +1,9 @@ using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; using Microsoft.Extensions.DependencyInjection; +using StackExchange.Redis; using Swashbuckle.AspNetCore.Swagger; using Volo.Abp; using Volo.Abp.Auditing; @@ -87,6 +89,10 @@ namespace BloggingService.Host options.IsEnabledForGetRequests = true; options.ApplicationName = "BloggingService"; }); + + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + context.Services.AddDataProtection() + .PersistKeysToStackExchangeRedis(redis, "MsDemo-DataProtection-Keys"); } public override void OnApplicationInitialization(ApplicationInitializationContext context) diff --git a/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityService.Host.csproj b/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityService.Host.csproj index 600dbb96df..4be0500443 100644 --- a/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityService.Host.csproj +++ b/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityService.Host.csproj @@ -19,6 +19,7 @@ + @@ -40,4 +41,12 @@ + + + + signed + + + + diff --git a/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs b/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs index 9dd68c9f39..2affd03367 100644 --- a/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs +++ b/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs @@ -1,5 +1,7 @@ using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; using Microsoft.Extensions.DependencyInjection; +using StackExchange.Redis; using Swashbuckle.AspNetCore.Swagger; using Volo.Abp; using Volo.Abp.Auditing; @@ -78,6 +80,10 @@ namespace IdentityService.Host options.IsEnabledForGetRequests = true; options.ApplicationName = "IdentityService"; }); + + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + context.Services.AddDataProtection() + .PersistKeysToStackExchangeRedis(redis, "MsDemo-DataProtection-Keys"); } public override void OnApplicationInitialization(ApplicationInitializationContext context) diff --git a/samples/MicroserviceDemo/microservices/ProductService.Host/ProductService.Host.csproj b/samples/MicroserviceDemo/microservices/ProductService.Host/ProductService.Host.csproj index cd3d255d3c..2b19692585 100644 --- a/samples/MicroserviceDemo/microservices/ProductService.Host/ProductService.Host.csproj +++ b/samples/MicroserviceDemo/microservices/ProductService.Host/ProductService.Host.csproj @@ -19,6 +19,7 @@ + @@ -40,9 +41,12 @@ - - - - + + + + signed + + + diff --git a/samples/MicroserviceDemo/microservices/ProductService.Host/ProductServiceHostModule.cs b/samples/MicroserviceDemo/microservices/ProductService.Host/ProductServiceHostModule.cs index c09fb4fcc1..6e08ad8e93 100644 --- a/samples/MicroserviceDemo/microservices/ProductService.Host/ProductServiceHostModule.cs +++ b/samples/MicroserviceDemo/microservices/ProductService.Host/ProductServiceHostModule.cs @@ -1,7 +1,9 @@ using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; using Microsoft.Extensions.DependencyInjection; using ProductManagement; using ProductManagement.EntityFrameworkCore; +using StackExchange.Redis; using Swashbuckle.AspNetCore.Swagger; using Volo.Abp; using Volo.Abp.Auditing; @@ -78,6 +80,10 @@ namespace ProductService.Host options.IsEnabledForGetRequests = true; options.ApplicationName = "ProductService"; }); + + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + context.Services.AddDataProtection() + .PersistKeysToStackExchangeRedis(redis, "MsDemo-DataProtection-Keys"); } public override void OnApplicationInitialization(ApplicationInitializationContext context)