mirror of
https://github.com/anjoy8/Blog.Core.git
synced 2024-09-20 23:48:27 +08:00
✨ 注册DataProtection fix#361
This commit is contained in:
parent
e06093cfbd
commit
0d5fb831de
|
@ -97,6 +97,7 @@ builder.Services.Configure<KestrelServerOptions>(x => x.AllowSynchronousIO = tru
|
|||
.Configure<IISServerOptions>(x => x.AllowSynchronousIO = true);
|
||||
|
||||
builder.Services.AddSession();
|
||||
builder.Services.AddDataProtectionSetup();
|
||||
builder.Services.AddControllers(o =>
|
||||
{
|
||||
o.Filters.Add(typeof(GlobalExceptionsFilter));
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<PackageReference Include="Com.Ctrip.Framework.Apollo.Configuration" Version="2.10.2" />
|
||||
<PackageReference Include="Consul" Version="1.7.14.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="8.0.6" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.1.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="8.0.0" />
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
using Blog.Core.Common;
|
||||
using Blog.Core.Common.Option;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace Blog.Core.Extensions.ServiceExtensions;
|
||||
|
||||
public static class DataProtectionSetup
|
||||
{
|
||||
public static void AddDataProtectionSetup(this IServiceCollection services)
|
||||
{
|
||||
var builder = services.AddDataProtection();
|
||||
|
||||
var redisOption = App.GetOptions<RedisOptions>();
|
||||
if (redisOption.Enable)
|
||||
{
|
||||
builder.PersistKeysToStackExchangeRedis(App.GetService<IConnectionMultiplexer>());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user