From 05503c6697b7c5683708a6d63922ea66fedd7a45 Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Fri, 9 Jun 2023 17:42:33 -0400 Subject: [PATCH] Removed IdentityServer --- ...OnAbp.IdentityService.Domain.Shared.csproj | 1 - .../IdentityServiceDomainSharedModule.cs | 5 +- ...ntityServiceModuleExtensionConfigurator.cs | 5 +- .../EShopOnAbp.IdentityService.Domain.csproj | 1 - .../IdentityServiceDomainModule.cs | 4 +- ...IdentityService.EntityFrameworkCore.csproj | 1 - .../IdentityServiceDbContext.cs | 34 +- ...ityServiceEfCoreEntityExtensionMappings.cs | 5 +- ...dentityServiceEntityFrameworkCoreModule.cs | 5 +- .../DbMigrations/IdentityServerDataSeeder.cs | 424 ------------------ ...IdentityServiceDatabaseMigrationChecker.cs | 2 - 11 files changed, 6 insertions(+), 481 deletions(-) delete mode 100644 services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/DbMigrations/IdentityServerDataSeeder.cs diff --git a/services/identity/src/EShopOnAbp.IdentityService.Domain.Shared/EShopOnAbp.IdentityService.Domain.Shared.csproj b/services/identity/src/EShopOnAbp.IdentityService.Domain.Shared/EShopOnAbp.IdentityService.Domain.Shared.csproj index 2a6aa168..d288b273 100644 --- a/services/identity/src/EShopOnAbp.IdentityService.Domain.Shared/EShopOnAbp.IdentityService.Domain.Shared.csproj +++ b/services/identity/src/EShopOnAbp.IdentityService.Domain.Shared/EShopOnAbp.IdentityService.Domain.Shared.csproj @@ -11,7 +11,6 @@ - diff --git a/services/identity/src/EShopOnAbp.IdentityService.Domain.Shared/IdentityServiceDomainSharedModule.cs b/services/identity/src/EShopOnAbp.IdentityService.Domain.Shared/IdentityServiceDomainSharedModule.cs index 8cd6fe24..caff74d2 100644 --- a/services/identity/src/EShopOnAbp.IdentityService.Domain.Shared/IdentityServiceDomainSharedModule.cs +++ b/services/identity/src/EShopOnAbp.IdentityService.Domain.Shared/IdentityServiceDomainSharedModule.cs @@ -1,8 +1,6 @@ using EShopOnAbp.IdentityService.Localization; using Volo.Abp.Identity; -using Volo.Abp.IdentityServer; using Volo.Abp.Localization; -using Volo.Abp.Localization.ExceptionHandling; using Volo.Abp.Modularity; using Volo.Abp.Validation.Localization; using Volo.Abp.VirtualFileSystem; @@ -10,8 +8,7 @@ using Volo.Abp.VirtualFileSystem; namespace EShopOnAbp.IdentityService { [DependsOn( - typeof(AbpIdentityDomainSharedModule), - typeof(AbpIdentityServerDomainSharedModule) + typeof(AbpIdentityDomainSharedModule) )] public class IdentityServiceDomainSharedModule : AbpModule { diff --git a/services/identity/src/EShopOnAbp.IdentityService.Domain.Shared/IdentityServiceModuleExtensionConfigurator.cs b/services/identity/src/EShopOnAbp.IdentityService.Domain.Shared/IdentityServiceModuleExtensionConfigurator.cs index 493336a1..e3aedaa1 100644 --- a/services/identity/src/EShopOnAbp.IdentityService.Domain.Shared/IdentityServiceModuleExtensionConfigurator.cs +++ b/services/identity/src/EShopOnAbp.IdentityService.Domain.Shared/IdentityServiceModuleExtensionConfigurator.cs @@ -1,7 +1,4 @@ -using System.ComponentModel.DataAnnotations; -using Volo.Abp.Identity; -using Volo.Abp.ObjectExtending; -using Volo.Abp.Threading; +using Volo.Abp.Threading; namespace EShopOnAbp.IdentityService { diff --git a/services/identity/src/EShopOnAbp.IdentityService.Domain/EShopOnAbp.IdentityService.Domain.csproj b/services/identity/src/EShopOnAbp.IdentityService.Domain/EShopOnAbp.IdentityService.Domain.csproj index 878dab3b..046adeca 100644 --- a/services/identity/src/EShopOnAbp.IdentityService.Domain/EShopOnAbp.IdentityService.Domain.csproj +++ b/services/identity/src/EShopOnAbp.IdentityService.Domain/EShopOnAbp.IdentityService.Domain.csproj @@ -11,7 +11,6 @@ - diff --git a/services/identity/src/EShopOnAbp.IdentityService.Domain/IdentityServiceDomainModule.cs b/services/identity/src/EShopOnAbp.IdentityService.Domain/IdentityServiceDomainModule.cs index 609aa10d..21a682dc 100644 --- a/services/identity/src/EShopOnAbp.IdentityService.Domain/IdentityServiceDomainModule.cs +++ b/services/identity/src/EShopOnAbp.IdentityService.Domain/IdentityServiceDomainModule.cs @@ -1,13 +1,11 @@ using Volo.Abp.Identity; -using Volo.Abp.IdentityServer; using Volo.Abp.Modularity; namespace EShopOnAbp.IdentityService { [DependsOn( typeof(IdentityServiceDomainSharedModule), - typeof(AbpIdentityDomainModule), - typeof(AbpIdentityServerDomainModule) + typeof(AbpIdentityDomainModule) )] public class IdentityServiceDomainModule : AbpModule { diff --git a/services/identity/src/EShopOnAbp.IdentityService.EntityFrameworkCore/EShopOnAbp.IdentityService.EntityFrameworkCore.csproj b/services/identity/src/EShopOnAbp.IdentityService.EntityFrameworkCore/EShopOnAbp.IdentityService.EntityFrameworkCore.csproj index 1077a773..42b82ccf 100644 --- a/services/identity/src/EShopOnAbp.IdentityService.EntityFrameworkCore/EShopOnAbp.IdentityService.EntityFrameworkCore.csproj +++ b/services/identity/src/EShopOnAbp.IdentityService.EntityFrameworkCore/EShopOnAbp.IdentityService.EntityFrameworkCore.csproj @@ -18,7 +18,6 @@ - diff --git a/services/identity/src/EShopOnAbp.IdentityService.EntityFrameworkCore/EntityFrameworkCore/IdentityServiceDbContext.cs b/services/identity/src/EShopOnAbp.IdentityService.EntityFrameworkCore/EntityFrameworkCore/IdentityServiceDbContext.cs index 716f233f..fbe952ea 100644 --- a/services/identity/src/EShopOnAbp.IdentityService.EntityFrameworkCore/EntityFrameworkCore/IdentityServiceDbContext.cs +++ b/services/identity/src/EShopOnAbp.IdentityService.EntityFrameworkCore/EntityFrameworkCore/IdentityServiceDbContext.cs @@ -3,13 +3,6 @@ using Volo.Abp.Data; using Volo.Abp.EntityFrameworkCore; using Volo.Abp.Identity; using Volo.Abp.Identity.EntityFrameworkCore; -using Volo.Abp.IdentityServer.ApiResources; -using Volo.Abp.IdentityServer.ApiScopes; -using Volo.Abp.IdentityServer.Clients; -using Volo.Abp.IdentityServer.Devices; -using Volo.Abp.IdentityServer.EntityFrameworkCore; -using Volo.Abp.IdentityServer.Grants; -using Volo.Abp.IdentityServer.IdentityResources; namespace EShopOnAbp.IdentityService.EntityFrameworkCore { @@ -23,8 +16,7 @@ namespace EShopOnAbp.IdentityService.EntityFrameworkCore * used modules (as explained above). See IdentityServiceMigrationsDbContext for migrations. */ [ConnectionStringName(IdentityServiceDbProperties.ConnectionStringName)] - public class IdentityServiceDbContext : AbpDbContext, IIdentityDbContext, - IIdentityServerDbContext + public class IdentityServiceDbContext : AbpDbContext, IIdentityDbContext { public DbSet Users { get; set; } public DbSet Roles { get; set; } @@ -32,29 +24,6 @@ namespace EShopOnAbp.IdentityService.EntityFrameworkCore public DbSet OrganizationUnits { get; set; } public DbSet SecurityLogs { get; set; } public DbSet LinkUsers { get; set; } - public DbSet ApiResources { get; set; } - public DbSet ApiResourceSecrets { get; set; } - public DbSet ApiResourceClaims { get; set; } - public DbSet ApiResourceScopes { get; set; } - public DbSet ApiResourceProperties { get; set; } - public DbSet ApiScopes { get; set; } - public DbSet ApiScopeClaims { get; set; } - public DbSet ApiScopeProperties { get; set; } - public DbSet IdentityResources { get; set; } - public DbSet IdentityClaims { get; set; } - public DbSet IdentityResourceProperties { get; set; } - public DbSet Clients { get; set; } - public DbSet ClientGrantTypes { get; set; } - public DbSet ClientRedirectUris { get; set; } - public DbSet ClientPostLogoutRedirectUris { get; set; } - public DbSet ClientScopes { get; set; } - public DbSet ClientSecrets { get; set; } - public DbSet ClientClaims { get; set; } - public DbSet ClientIdPRestrictions { get; set; } - public DbSet ClientCorsOrigins { get; set; } - public DbSet ClientProperties { get; set; } - public DbSet PersistedGrants { get; set; } - public DbSet DeviceFlowCodes { get; set; } public IdentityServiceDbContext(DbContextOptions options) : base(options) @@ -66,7 +35,6 @@ namespace EShopOnAbp.IdentityService.EntityFrameworkCore base.OnModelCreating(builder); builder.ConfigureIdentity(); - builder.ConfigureIdentityServer(); } } } \ No newline at end of file diff --git a/services/identity/src/EShopOnAbp.IdentityService.EntityFrameworkCore/EntityFrameworkCore/IdentityServiceEfCoreEntityExtensionMappings.cs b/services/identity/src/EShopOnAbp.IdentityService.EntityFrameworkCore/EntityFrameworkCore/IdentityServiceEfCoreEntityExtensionMappings.cs index 7566b3eb..40c0972e 100644 --- a/services/identity/src/EShopOnAbp.IdentityService.EntityFrameworkCore/EntityFrameworkCore/IdentityServiceEfCoreEntityExtensionMappings.cs +++ b/services/identity/src/EShopOnAbp.IdentityService.EntityFrameworkCore/EntityFrameworkCore/IdentityServiceEfCoreEntityExtensionMappings.cs @@ -1,7 +1,4 @@ -using Microsoft.EntityFrameworkCore; -using Volo.Abp.Identity; -using Volo.Abp.ObjectExtending; -using Volo.Abp.Threading; +using Volo.Abp.Threading; namespace EShopOnAbp.IdentityService.EntityFrameworkCore { diff --git a/services/identity/src/EShopOnAbp.IdentityService.EntityFrameworkCore/EntityFrameworkCore/IdentityServiceEntityFrameworkCoreModule.cs b/services/identity/src/EShopOnAbp.IdentityService.EntityFrameworkCore/EntityFrameworkCore/IdentityServiceEntityFrameworkCoreModule.cs index fb0dbaf9..ba92f336 100644 --- a/services/identity/src/EShopOnAbp.IdentityService.EntityFrameworkCore/EntityFrameworkCore/IdentityServiceEntityFrameworkCoreModule.cs +++ b/services/identity/src/EShopOnAbp.IdentityService.EntityFrameworkCore/EntityFrameworkCore/IdentityServiceEntityFrameworkCoreModule.cs @@ -3,7 +3,6 @@ using Microsoft.Extensions.DependencyInjection; using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore.PostgreSql; using Volo.Abp.Identity.EntityFrameworkCore; -using Volo.Abp.IdentityServer.EntityFrameworkCore; using Volo.Abp.Modularity; namespace EShopOnAbp.IdentityService.EntityFrameworkCore @@ -11,8 +10,7 @@ namespace EShopOnAbp.IdentityService.EntityFrameworkCore [DependsOn( typeof(IdentityServiceDomainModule), typeof(AbpEntityFrameworkCorePostgreSqlModule), - typeof(AbpIdentityEntityFrameworkCoreModule), - typeof(AbpIdentityServerEntityFrameworkCoreModule) + typeof(AbpIdentityEntityFrameworkCoreModule) )] public class IdentityServiceEntityFrameworkCoreModule : AbpModule { @@ -26,7 +24,6 @@ namespace EShopOnAbp.IdentityService.EntityFrameworkCore context.Services.AddAbpDbContext(options => { options.ReplaceDbContext(); - options.ReplaceDbContext(); options.AddDefaultRepositories(includeAllEntities: true); }); diff --git a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/DbMigrations/IdentityServerDataSeeder.cs b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/DbMigrations/IdentityServerDataSeeder.cs deleted file mode 100644 index 9ce1c9a2..00000000 --- a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/DbMigrations/IdentityServerDataSeeder.cs +++ /dev/null @@ -1,424 +0,0 @@ -using IdentityServer4.Models; -using Microsoft.Extensions.Configuration; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Volo.Abp.Authorization.Permissions; -using Volo.Abp.Data; -using Volo.Abp.DependencyInjection; -using Volo.Abp.Guids; -using Volo.Abp.Identity; -using Volo.Abp.IdentityServer.ApiResources; -using Volo.Abp.IdentityServer.ApiScopes; -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; -using ApiScope = Volo.Abp.IdentityServer.ApiScopes.ApiScope; -using Client = Volo.Abp.IdentityServer.Clients.Client; - -namespace EShopOnAbp.IdentityService.DbMigrations; - -public class IdentityServerDataSeeder : IDataSeedContributor, ITransientDependency -{ - private readonly IApiResourceRepository _apiResourceRepository; - private readonly IApiScopeRepository _apiScopeRepository; - private readonly IClientRepository _clientRepository; - private readonly IIdentityResourceDataSeeder _identityResourceDataSeeder; - private readonly IGuidGenerator _guidGenerator; - private readonly IPermissionDataSeeder _permissionDataSeeder; - private readonly IConfiguration _configuration; - private readonly ICurrentTenant _currentTenant; - - public IdentityServerDataSeeder( - IClientRepository clientRepository, - IApiResourceRepository apiResourceRepository, - IApiScopeRepository apiScopeRepository, - IIdentityResourceDataSeeder identityResourceDataSeeder, - IGuidGenerator guidGenerator, - IPermissionDataSeeder permissionDataSeeder, - IConfiguration configuration, - ICurrentTenant currentTenant) - { - _clientRepository = clientRepository; - _apiResourceRepository = apiResourceRepository; - _apiScopeRepository = apiScopeRepository; - _identityResourceDataSeeder = identityResourceDataSeeder; - _guidGenerator = guidGenerator; - _permissionDataSeeder = permissionDataSeeder; - _configuration = configuration; - _currentTenant = currentTenant; - } - - public virtual Task SeedAsync(DataSeedContext context) - { - return SeedAsync(); - } - - [UnitOfWork] - public virtual async Task SeedAsync() - { - using (_currentTenant.Change(null)) - { - await _identityResourceDataSeeder.CreateStandardResourcesAsync(); - await CreateApiResourcesAsync(); - await CreateApiScopesAsync(); - await CreateSwaggerClientsAsync(); - await CreateClientsAsync(); - } - } - - private async Task CreateApiResourcesAsync() - { - var commonApiUserClaims = new[] - { - "email", - "email_verified", - "name", - "phone_number", - "phone_number_verified", - "role" - }; - - await CreateApiResourceAsync("AccountService", commonApiUserClaims); - await CreateApiResourceAsync("IdentityService", commonApiUserClaims); - await CreateApiResourceAsync("AdministrationService", commonApiUserClaims); - await CreateApiResourceAsync("CatalogService", commonApiUserClaims); - await CreateApiResourceAsync("BasketService", commonApiUserClaims); - await CreateApiResourceAsync("OrderingService", commonApiUserClaims); - await CreateApiResourceAsync("PaymentService", commonApiUserClaims); - await CreateApiResourceAsync("CmskitService", commonApiUserClaims); - } - - private async Task CreateApiScopesAsync() - { - await CreateApiScopeAsync("AccountService"); - await CreateApiScopeAsync("IdentityService"); - await CreateApiScopeAsync("AdministrationService"); - await CreateApiScopeAsync("CatalogService"); - await CreateApiScopeAsync("BasketService"); - await CreateApiScopeAsync("OrderingService"); - await CreateApiScopeAsync("PaymentService"); - await CreateApiScopeAsync("CmskitService"); - } - - private async Task CreateSwaggerClientsAsync() - { - await CreateWebGatewaySwaggerClientAsync("WebGateway", - new[] - { - "AccountService", - "IdentityService", - "AdministrationService", - "CatalogService", - "BasketService", - "PaymentService", - "OrderingService", - "CmskitService" - }); - } - - private async Task CreateWebGatewaySwaggerClientAsync(string name, string[] scopes = null) - { - var commonScopes = new[] - { - "email", - "openid", - "profile", - "role", - "phone", - "address" - }; - scopes ??= new[] { name }; - - // Swagger Client - var swaggerClientId = $"{name}_Swagger"; - if (!swaggerClientId.IsNullOrWhiteSpace()) - { - var webGatewaySwaggerRootUrl = _configuration[$"IdentityServerClients:{name}:RootUrl"].TrimEnd('/'); - var publicWebGatewayRootUrl = _configuration[$"IdentityServerClients:PublicWebGateway:RootUrl"].TrimEnd('/'); - var accountServiceRootUrl = _configuration[$"IdentityServerClients:AccountService:RootUrl"].TrimEnd('/'); - var identityServiceRootUrl = _configuration[$"IdentityServerClients:IdentityService:RootUrl"].TrimEnd('/'); - var administrationServiceRootUrl = _configuration[$"IdentityServerClients:AdministrationService:RootUrl"].TrimEnd('/'); - var catalogServiceRootUrl = _configuration[$"IdentityServerClients:CatalogService:RootUrl"].TrimEnd('/'); - var basketServiceRootUrl = _configuration[$"IdentityServerClients:BasketService:RootUrl"].TrimEnd('/'); - var orderingServiceRootUrl = _configuration[$"IdentityServerClients:OrderingService:RootUrl"].TrimEnd('/'); - var paymentServiceRootUrl = _configuration[$"IdentityServerClients:PaymentService:RootUrl"].TrimEnd('/'); - var cmskitServiceRootUrl = _configuration[$"IdentityServerClients:CmskitService:RootUrl"].TrimEnd('/'); - - await CreateClientAsync( - name: swaggerClientId, - scopes: commonScopes.Union(scopes), - grantTypes: new[] { "authorization_code" }, - secret: "1q2w3e*".Sha256(), - requireClientSecret: false, - redirectUris: new List - { - $"{webGatewaySwaggerRootUrl}/swagger/oauth2-redirect.html", // WebGateway redirect uri - $"{publicWebGatewayRootUrl}/swagger/oauth2-redirect.html", // PublicWebGateway redirect uri - $"{accountServiceRootUrl}/swagger/oauth2-redirect.html", // AccountService redirect uri - $"{identityServiceRootUrl}/swagger/oauth2-redirect.html", // IdentityService redirect uri - $"{administrationServiceRootUrl}/swagger/oauth2-redirect.html", // AdministrationService redirect uri - $"{catalogServiceRootUrl}/swagger/oauth2-redirect.html", // CatalogService redirect uri - $"{basketServiceRootUrl}/swagger/oauth2-redirect.html", // BasketService redirect uri - $"{orderingServiceRootUrl}/swagger/oauth2-redirect.html", // OrderingService redirect uri - $"{paymentServiceRootUrl}/swagger/oauth2-redirect.html", // PaymentService redirect uri - $"{cmskitServiceRootUrl}/swagger/oauth2-redirect.html" // CmskitService redirect uri - }, - corsOrigins: new[] - { - webGatewaySwaggerRootUrl.RemovePostFix("/"), - publicWebGatewayRootUrl.RemovePostFix("/"), - accountServiceRootUrl.RemovePostFix("/"), - identityServiceRootUrl.RemovePostFix("/"), - administrationServiceRootUrl.RemovePostFix("/"), - catalogServiceRootUrl.RemovePostFix("/"), - basketServiceRootUrl.RemovePostFix("/"), - orderingServiceRootUrl.RemovePostFix("/"), - paymentServiceRootUrl.RemovePostFix("/"), - cmskitServiceRootUrl.RemovePostFix("/") - } - ); - } - } - - private async Task CreateApiResourceAsync(string name, IEnumerable claims) - { - var apiResource = await _apiResourceRepository.FindByNameAsync(name); - if (apiResource == null) - { - apiResource = await _apiResourceRepository.InsertAsync( - new ApiResource( - _guidGenerator.Create(), - name, - name + " API" - ), - autoSave: true - ); - } - - foreach (var claim in claims) - { - if (apiResource.FindClaim(claim) == null) - { - apiResource.AddUserClaim(claim); - } - } - - return await _apiResourceRepository.UpdateAsync(apiResource); - } - - private async Task CreateApiScopeAsync(string name) - { - var apiScope = await _apiScopeRepository.FindByNameAsync(name); - if (apiScope == null) - { - apiScope = await _apiScopeRepository.InsertAsync( - new ApiScope( - _guidGenerator.Create(), - name, - name + " API" - ), - autoSave: true - ); - } - - return apiScope; - } - - private async Task CreateClientsAsync() - { - var commonScopes = new[] - { - "email", - "openid", - "profile", - "role", - "phone", - "address" - }; - - //Public Web Client - var publicWebClientRootUrl = _configuration["IdentityServerClients:PublicWeb:RootUrl"] - .EnsureEndsWith('/'); - await CreateClientAsync( - name: "PublicWeb", - scopes: commonScopes.Union(new[] - { - "AccountService", - "AdministrationService", - "CatalogService", - "BasketService", - "PaymentService", - "OrderingService", - "CmskitService" - }), - grantTypes: new[] { "hybrid" }, - secret: "1q2w3e*".Sha256(), - redirectUris: new List { $"{publicWebClientRootUrl}signin-oidc" }, - postLogoutRedirectUri: $"{publicWebClientRootUrl}signout-callback-oidc", - frontChannelLogoutUri: $"{publicWebClientRootUrl}Account/FrontChannelLogout", - corsOrigins: new[] { publicWebClientRootUrl.RemovePostFix("/") } - ); - - //Angular Client - var angularClientRootUrl = - _configuration["IdentityServerClients:Web:RootUrl"].TrimEnd('/'); - await CreateClientAsync( - name: "Web", - scopes: commonScopes.Union(new[] - { - "AccountService", - "IdentityService", - "AdministrationService", - "CatalogService", - "OrderingService", - "CmskitService" - }), - grantTypes: new[] { "authorization_code", "LinkLogin", "password" }, - secret: "1q2w3e*".Sha256(), - requirePkce: true, - requireClientSecret: false, - redirectUris: new List { $"{angularClientRootUrl}" }, - postLogoutRedirectUri: $"{angularClientRootUrl}", - corsOrigins: new[] { angularClientRootUrl } - ); - - //Administration Service Client - await CreateClientAsync( - name: "EShopOnAbp_AdministrationService", - scopes: commonScopes.Union(new[] - { - "IdentityService" - }), - grantTypes: new[] { "client_credentials" }, - secret: "1q2w3e*".Sha256(), - permissions: new[] { IdentityPermissions.Users.Default } - ); - - //Cmskit Service Client - await CreateClientAsync( - name: "EShopOnAbp_CmskitService", - scopes: commonScopes.Union(new[] - { - "IdentityService" - }), - grantTypes: new[] { "client_credentials" }, - secret: "1q2w3e*".Sha256(), - permissions: new[] { IdentityPermissions.UserLookup.Default } - ); - } - - private async Task CreateClientAsync( - string name, - IEnumerable scopes, - IEnumerable grantTypes, - string secret = null, - List redirectUris = null, - string postLogoutRedirectUri = null, - string frontChannelLogoutUri = null, - bool requireClientSecret = true, - bool requirePkce = false, - IEnumerable permissions = null, - IEnumerable corsOrigins = null) - { - var client = await _clientRepository.FindByClientIdAsync(name); - if (client == null) - { - client = await _clientRepository.InsertAsync( - new Client( - _guidGenerator.Create(), - name - ) - { - ClientName = name, - ProtocolType = "oidc", - Description = name, - AlwaysIncludeUserClaimsInIdToken = true, - AllowOfflineAccess = true, - AbsoluteRefreshTokenLifetime = 31536000, //365 days - AccessTokenLifetime = 31536000, //365 days - AuthorizationCodeLifetime = 300, - IdentityTokenLifetime = 300, - RequireConsent = false, - FrontChannelLogoutUri = frontChannelLogoutUri, - RequireClientSecret = requireClientSecret, - RequirePkce = requirePkce - }, - autoSave: true - ); - } - - foreach (var scope in scopes) - { - if (client.FindScope(scope) == null) - { - client.AddScope(scope); - } - } - - foreach (var grantType in grantTypes) - { - if (client.FindGrantType(grantType) == null) - { - client.AddGrantType(grantType); - } - } - - if (!secret.IsNullOrEmpty()) - { - if (client.FindSecret(secret) == null) - { - client.AddSecret(secret); - } - } - - if (redirectUris != null) - { - foreach (var redirectUri in redirectUris) - { - if (redirectUri != null) - { - if (client.FindRedirectUri(redirectUri) == null) - { - client.AddRedirectUri(redirectUri); - } - } - } - } - - if (postLogoutRedirectUri != null) - { - if (client.FindPostLogoutRedirectUri(postLogoutRedirectUri) == null) - { - client.AddPostLogoutRedirectUri(postLogoutRedirectUri); - } - } - - if (permissions != null) - { - await _permissionDataSeeder.SeedAsync( - ClientPermissionValueProvider.ProviderName, - name, - permissions, - null - ); - } - - if (corsOrigins != null) - { - foreach (var origin in corsOrigins) - { - if (!origin.IsNullOrWhiteSpace() && client.FindCorsOrigin(origin) == null) - { - client.AddCorsOrigin(origin); - } - } - } - - return await _clientRepository.UpdateAsync(client); - } -} \ No newline at end of file diff --git a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/DbMigrations/IdentityServiceDatabaseMigrationChecker.cs b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/DbMigrations/IdentityServiceDatabaseMigrationChecker.cs index b60910e0..27e67164 100644 --- a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/DbMigrations/IdentityServiceDatabaseMigrationChecker.cs +++ b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/DbMigrations/IdentityServiceDatabaseMigrationChecker.cs @@ -1,9 +1,7 @@ using EShopOnAbp.IdentityService.EntityFrameworkCore; using System; -using System.Threading.Tasks; using EShopOnAbp.Shared.Hosting.Microservices.DbMigrations.EfCore; using Volo.Abp.EventBus.Distributed; -using Volo.Abp.EventBus.Local; using Volo.Abp.MultiTenancy; using Volo.Abp.Uow; using Volo.Abp.DistributedLocking;