Use OpenIddict with real db instead of inmemory (#14465)
* Add OpenIddict tables to database (#14449) * Added migrations to install EF Core OpenIddict tables * Handle Install of ef core data (Needs to be outside of transaction * Cleanup and renaming, as these things will be reused for more than openiddict in the future * Cleanup * Extract db context setup * Minor cleanup --------- Co-authored-by: Nikolaj <nikolajlauridsen@protonmail.ch> * Use OpenIddict from DB instead of InMemoryDb * Do not try to clean up, while not it run mode * Fixed tests * Clean up --------- Co-authored-by: Nikolaj <nikolajlauridsen@protonmail.ch> Co-authored-by: Elitsa <elm@umbraco.dk>
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using OpenIddict.Abstractions;
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.HostedServices;
|
||||
|
||||
@@ -14,17 +16,24 @@ public class OpenIddictCleanup : RecurringHostedServiceBase
|
||||
|
||||
private readonly ILogger<OpenIddictCleanup> _logger;
|
||||
private readonly IServiceProvider _provider;
|
||||
private readonly IRuntimeState _runtimeState;
|
||||
|
||||
public OpenIddictCleanup(
|
||||
ILogger<OpenIddictCleanup> logger, IServiceProvider provider)
|
||||
ILogger<OpenIddictCleanup> logger, IServiceProvider provider, IRuntimeState runtimeState)
|
||||
: base(logger, TimeSpan.FromHours(1), TimeSpan.FromMinutes(5))
|
||||
{
|
||||
_logger = logger;
|
||||
_provider = provider;
|
||||
_runtimeState = runtimeState;
|
||||
}
|
||||
|
||||
public override async Task PerformExecuteAsync(object? state)
|
||||
{
|
||||
if (_runtimeState.Level < RuntimeLevel.Run)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// hosted services are registered as singletons, but this particular one consumes scoped services... so
|
||||
// we have to fetch the service dependencies manually using a new scope per invocation.
|
||||
IServiceScope scope = _provider.CreateScope();
|
||||
|
||||
Reference in New Issue
Block a user