From cc9ea5983cae04be8044b00f3dbd344bb61c49e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 3 Jan 2020 15:59:19 +0300 Subject: [PATCH] Add TokenCleanupBackgroundWorker to the BackgroundWorkerManager. --- .../AbpIdentityServerDomainModule.cs | 17 +++++++++++++++++ .../Tokens/TokenCleanupOptions.cs | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerDomainModule.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerDomainModule.cs index 7c22dccf0e..fa1a65f556 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerDomainModule.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerDomainModule.cs @@ -2,9 +2,12 @@ using IdentityServer4.Stores; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; +using Microsoft.Extensions.Options; using Volo.Abp.AutoMapper; +using Volo.Abp.BackgroundWorkers; using Volo.Abp.Caching; using Volo.Abp.Identity; +using Volo.Abp.IdentityServer.Tokens; using Volo.Abp.Modularity; using Volo.Abp.Security; using Volo.Abp.Validation; @@ -76,5 +79,19 @@ namespace Volo.Abp.IdentityServer identityServerBuilder.AddInMemoryIdentityResources(configuration.GetSection("IdentityServer:IdentityResources")); } } + + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var options = context.ServiceProvider.GetRequiredService>().Value; + if (options.IsCleanupEnabled) + { + context.ServiceProvider + .GetRequiredService() + .Add( + context.ServiceProvider + .GetRequiredService() + ); + } + } } } diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Tokens/TokenCleanupOptions.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Tokens/TokenCleanupOptions.cs index 3252008506..816ef6af15 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Tokens/TokenCleanupOptions.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Tokens/TokenCleanupOptions.cs @@ -29,6 +29,6 @@ namespace Volo.Abp.IdentityServer.Tokens /// If is false, /// this property is ignored and the cleanup worker doesn't work for this application instance. /// - public bool EnableCleanup { get; set; } = true; + public bool IsCleanupEnabled { get; set; } = true; } } \ No newline at end of file