Browse Source

Add TokenCleanupBackgroundWorker to the BackgroundWorkerManager.

pull/2545/head
Halil İbrahim Kalkan 7 years ago
parent
commit
cc9ea5983c
  1. 17
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerDomainModule.cs
  2. 2
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Tokens/TokenCleanupOptions.cs

17
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerDomainModule.cs

@ -2,9 +2,12 @@
using IdentityServer4.Stores; using IdentityServer4.Stores;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
using Volo.Abp.AutoMapper; using Volo.Abp.AutoMapper;
using Volo.Abp.BackgroundWorkers;
using Volo.Abp.Caching; using Volo.Abp.Caching;
using Volo.Abp.Identity; using Volo.Abp.Identity;
using Volo.Abp.IdentityServer.Tokens;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.Security; using Volo.Abp.Security;
using Volo.Abp.Validation; using Volo.Abp.Validation;
@ -76,5 +79,19 @@ namespace Volo.Abp.IdentityServer
identityServerBuilder.AddInMemoryIdentityResources(configuration.GetSection("IdentityServer:IdentityResources")); identityServerBuilder.AddInMemoryIdentityResources(configuration.GetSection("IdentityServer:IdentityResources"));
} }
} }
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var options = context.ServiceProvider.GetRequiredService<IOptions<TokenCleanupOptions>>().Value;
if (options.IsCleanupEnabled)
{
context.ServiceProvider
.GetRequiredService<IBackgroundWorkerManager>()
.Add(
context.ServiceProvider
.GetRequiredService<TokenCleanupBackgroundWorker>()
);
}
}
} }
} }

2
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Tokens/TokenCleanupOptions.cs

@ -29,6 +29,6 @@ namespace Volo.Abp.IdentityServer.Tokens
/// If <see cref="AbpBackgroundWorkerOptions.IsEnabled"/> is false, /// If <see cref="AbpBackgroundWorkerOptions.IsEnabled"/> is false,
/// this property is ignored and the cleanup worker doesn't work for this application instance. /// this property is ignored and the cleanup worker doesn't work for this application instance.
/// </summary> /// </summary>
public bool EnableCleanup { get; set; } = true; public bool IsCleanupEnabled { get; set; } = true;
} }
} }
Loading…
Cancel
Save