Skip to content

Commit

Permalink
Fixed seeding not working due to missing configuration bind
Browse files Browse the repository at this point in the history
  • Loading branch information
Brice-xCIT committed Jan 13, 2021
1 parent 5b43d76 commit 93d5e3a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Skoruba.IdentityServer4.Admin.EntityFramework.Shared.Configuration
{
public class IdentityDataConfiguration
public class IdentityData
{
public List<Role> Roles { get; set; }
public List<User> Users { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Skoruba.IdentityServer4.Admin.EntityFramework.Shared.Configuration
{
public class IdentityServerDataConfiguration
public class IdentityServerData
{
public List<Client> Clients { get; set; } = new List<Client>();
public List<IdentityResource> IdentityResources { get; set; } = new List<IdentityResource>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ public static async Task EnsureSeedDataAsync<TIdentityServerDbContext, TUser, TR
var context = scope.ServiceProvider.GetRequiredService<TIdentityServerDbContext>();
var userManager = scope.ServiceProvider.GetRequiredService<UserManager<TUser>>();
var roleManager = scope.ServiceProvider.GetRequiredService<RoleManager<TRole>>();
var idsDataConfiguration = scope.ServiceProvider.GetRequiredService<IdentityServerDataConfiguration>();
var idDataConfiguration = scope.ServiceProvider.GetRequiredService<IdentityDataConfiguration>();
var idsDataConfiguration = scope.ServiceProvider.GetRequiredService<IdentityServerData>();
var idDataConfiguration = scope.ServiceProvider.GetRequiredService<IdentityData>();

await EnsureSeedIdentityServerData(context, idsDataConfiguration);
await EnsureSeedIdentityData(userManager, roleManager, idDataConfiguration);
Expand All @@ -121,7 +121,7 @@ public static async Task EnsureSeedDataAsync<TIdentityServerDbContext, TUser, TR
/// Generate default admin user / role
/// </summary>
private static async Task EnsureSeedIdentityData<TUser, TRole>(UserManager<TUser> userManager,
RoleManager<TRole> roleManager, IdentityDataConfiguration identityDataConfiguration)
RoleManager<TRole> roleManager, IdentityData identityDataConfiguration)
where TUser : IdentityUser, new()
where TRole : IdentityRole, new()
{
Expand Down Expand Up @@ -190,7 +190,7 @@ private static async Task EnsureSeedIdentityData<TUser, TRole>(UserManager<TUser
/// <summary>
/// Generate default clients, identity and api resources
/// </summary>
private static async Task EnsureSeedIdentityServerData<TIdentityServerDbContext>(TIdentityServerDbContext context, IdentityServerDataConfiguration identityServerDataConfiguration)
private static async Task EnsureSeedIdentityServerData<TIdentityServerDbContext>(TIdentityServerDbContext context, IdentityServerData identityServerDataConfiguration)
where TIdentityServerDbContext : DbContext, IAdminConfigurationDbContext
{
foreach (var resource in identityServerDataConfiguration.IdentityResources)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ public class IdentityServer4AdminUIOptions
/// <summary>
/// Identity data to seed the databases.
/// </summary>
public IdentityDataConfiguration IdentityData { get; set; } = new IdentityDataConfiguration();
public IdentityData IdentityData { get; set; } = new IdentityData();

/// <summary>
/// Identity server data to seed the databases.
/// </summary>
public IdentityServerDataConfiguration IdentityServerData { get; set; } = new IdentityServerDataConfiguration();
public IdentityServerData IdentityServerData { get; set; } = new IdentityServerData();

/// <summary>
/// The settings for security features.
Expand Down Expand Up @@ -106,6 +106,8 @@ public void BindConfiguration(IConfiguration configuration)
IdentityConfigureAction = options => configuration.GetSection(nameof(IdentityOptions)).Bind(options);
configuration.GetSection(nameof(SecurityConfiguration)).Bind(Security);
configuration.GetSection(nameof(HttpConfiguration)).Bind(Http);
configuration.GetSection(nameof(Skoruba.IdentityServer4.Admin.EntityFramework.Shared.Configuration.IdentityServerData)).Bind(IdentityServerData);
configuration.GetSection(nameof(Skoruba.IdentityServer4.Admin.EntityFramework.Shared.Configuration.IdentityData)).Bind(IdentityData);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.DataProtection.EntityFrameworkCore" Version="3.1.6" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.EntityFrameworkCore" Version="3.1.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.6" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="3.1.6" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="3.1.9" />
<PackageReference Include="AspNetCore.HealthChecks.MySql" Version="3.1.1" />
<PackageReference Include="AspNetCore.HealthChecks.NpgSql" Version="3.1.1" />
<PackageReference Include="AspNetCore.HealthChecks.OpenIdConnectServer" Version="3.1.1" />
Expand Down

This file was deleted.

0 comments on commit 93d5e3a

Please sign in to comment.