Persist external authentication in identity shell

This commit is contained in:
Sipke Schoorstra 2026-07-27 02:25:41 +02:00
parent 0fa7657b30
commit 75a3216ae8
No known key found for this signature in database
GPG key ID: 5C10502B28A4268F
2 changed files with 21 additions and 0 deletions

View file

@ -14,6 +14,7 @@ public abstract class EFCoreIdentityPersistenceShellFeatureBase : PersistenceShe
{
protected override void OnConfiguring(IServiceCollection services)
{
services.AddExternalAuthenticationEntityFrameworkCore();
services.AddScoped<IUserStore, EFCoreUserStore>();
services.AddScoped<IApplicationStore, EFCoreApplicationStore>();
services.AddScoped<IRoleStore, EFCoreRoleStore>();

View file

@ -1,5 +1,7 @@
using Elsa.ExternalAuthentication.Contracts;
using Elsa.ExternalAuthentication.Services;
using Elsa.Persistence.EFCore.Modules.ExternalAuthentication;
using Elsa.Persistence.EFCore.Sqlite.ShellFeatures.Identity;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.ExternalAuthentication.IntegrationTests.Persistence;
@ -17,4 +19,22 @@ public class ExternalAuthenticationPersistenceRegistrationTests
Assert.IsType<HmacExternalAuthenticationHandleHasher>(
serviceProvider.GetRequiredService<IExternalAuthenticationHandleHasher>());
}
[Fact]
public void SqliteIdentityShellFeatureUsesEntityFrameworkCoreForExternalAuthentication()
{
var services = new ServiceCollection();
services.AddExternalAuthenticationServices();
var feature = new SqliteIdentityPersistenceShellFeature
{
ConnectionString = "Data Source=:memory:"
};
feature.ConfigureServices(services);
var registration = services.Last(x => x.ServiceType == typeof(IIdentityProviderConnectionStore));
Assert.Equal(typeof(EFCoreIdentityProviderConnectionStore), registration.ImplementationType);
Assert.Equal(ServiceLifetime.Scoped, registration.Lifetime);
}
}