|
|
|
@ -10,6 +10,7 @@ using Volo.Abp.Guids;
|
|
|
|
|
using Volo.Abp.IdentityServer.ApiResources;
|
|
|
|
|
using Volo.Abp.IdentityServer.Clients;
|
|
|
|
|
using Volo.Abp.IdentityServer.IdentityResources;
|
|
|
|
|
using Volo.Abp.MultiTenancy;
|
|
|
|
|
using Volo.Abp.PermissionManagement;
|
|
|
|
|
using Volo.Abp.Uow;
|
|
|
|
|
using ApiResource = Volo.Abp.IdentityServer.ApiResources.ApiResource;
|
|
|
|
@ -25,6 +26,7 @@ namespace MyCompanyName.MyProjectName.IdentityServer
|
|
|
|
|
private readonly IGuidGenerator _guidGenerator;
|
|
|
|
|
private readonly IPermissionDataSeeder _permissionDataSeeder;
|
|
|
|
|
private readonly IConfiguration _configuration;
|
|
|
|
|
private readonly ICurrentTenant _currentTenant;
|
|
|
|
|
|
|
|
|
|
public IdentityServerDataSeedContributor(
|
|
|
|
|
IClientRepository clientRepository,
|
|
|
|
@ -32,7 +34,8 @@ namespace MyCompanyName.MyProjectName.IdentityServer
|
|
|
|
|
IIdentityResourceDataSeeder identityResourceDataSeeder,
|
|
|
|
|
IGuidGenerator guidGenerator,
|
|
|
|
|
IPermissionDataSeeder permissionDataSeeder,
|
|
|
|
|
IConfiguration configuration)
|
|
|
|
|
IConfiguration configuration,
|
|
|
|
|
ICurrentTenant currentTenant)
|
|
|
|
|
{
|
|
|
|
|
_clientRepository = clientRepository;
|
|
|
|
|
_apiResourceRepository = apiResourceRepository;
|
|
|
|
@ -40,14 +43,18 @@ namespace MyCompanyName.MyProjectName.IdentityServer
|
|
|
|
|
_guidGenerator = guidGenerator;
|
|
|
|
|
_permissionDataSeeder = permissionDataSeeder;
|
|
|
|
|
_configuration = configuration;
|
|
|
|
|
_currentTenant = currentTenant;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[UnitOfWork]
|
|
|
|
|
public virtual async Task SeedAsync(DataSeedContext context)
|
|
|
|
|
{
|
|
|
|
|
await _identityResourceDataSeeder.CreateStandardResourcesAsync();
|
|
|
|
|
await CreateApiResourcesAsync();
|
|
|
|
|
await CreateClientsAsync();
|
|
|
|
|
using (_currentTenant.Change(context?.TenantId))
|
|
|
|
|
{
|
|
|
|
|
await _identityResourceDataSeeder.CreateStandardResourcesAsync();
|
|
|
|
|
await CreateApiResourcesAsync();
|
|
|
|
|
await CreateClientsAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task CreateApiResourcesAsync()
|
|
|
|
|