diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerConsts.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerConsts.cs deleted file mode 100644 index 99ec29758f..0000000000 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerConsts.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Volo.Abp.IdentityServer -{ - public static class AbpIdentityServerConsts - { - public const string DefaultDbTablePrefix = "IdentityServer"; - - public const string DefaultDbSchema = null; - - public const string ConnectionStringName = "AbpIdentityServer"; - } -} diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerDbProperties.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerDbProperties.cs new file mode 100644 index 0000000000..751c33ccd5 --- /dev/null +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerDbProperties.cs @@ -0,0 +1,11 @@ +namespace Volo.Abp.IdentityServer +{ + public static class AbpIdentityServerDbProperties + { + public static string DbTablePrefix { get; } = "IdentityServer"; + + public static string DbSchema { get; } = null; + + public const string ConnectionStringName = "AbpIdentityServer"; + } +} diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IIdentityServerDbContext.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IIdentityServerDbContext.cs index 6e4941c119..3c7f425dc9 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IIdentityServerDbContext.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IIdentityServerDbContext.cs @@ -8,7 +8,7 @@ using Volo.Abp.IdentityServer.IdentityResources; namespace Volo.Abp.IdentityServer.EntityFrameworkCore { - [ConnectionStringName(AbpIdentityServerConsts.ConnectionStringName)] + [ConnectionStringName(AbpIdentityServerDbProperties.ConnectionStringName)] public interface IIdentityServerDbContext : IEfCoreDbContext { DbSet ApiResources { get; set; } diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContext.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContext.cs index 43bc14a303..800aa8b8be 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContext.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContext.cs @@ -8,13 +8,9 @@ using Volo.Abp.IdentityServer.IdentityResources; namespace Volo.Abp.IdentityServer.EntityFrameworkCore { - [ConnectionStringName(AbpIdentityServerConsts.ConnectionStringName)] + [ConnectionStringName(AbpIdentityServerDbProperties.ConnectionStringName)] public class IdentityServerDbContext : AbpDbContext, IIdentityServerDbContext { - public static string TablePrefix { get; set; } = AbpIdentityServerConsts.DefaultDbTablePrefix; - - public static string Schema { get; set; } = AbpIdentityServerConsts.DefaultDbSchema; - public DbSet ApiResources { get; set; } public DbSet ApiSecrets { get; set; } @@ -60,7 +56,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); - builder.ConfigureIdentityServer(TablePrefix, Schema); + builder.ConfigureIdentityServer(); } } } diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs index 58fb39f8a5..a9b1f1fe33 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs @@ -1,5 +1,5 @@ -using System.Collections.Generic; -using JetBrains.Annotations; +using System; +using System.Collections.Generic; using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; using Volo.Abp.EntityFrameworkCore.Modeling; @@ -13,20 +13,21 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore public static class IdentityServerDbContextModelCreatingExtensions { public static void ConfigureIdentityServer( - this ModelBuilder builder, - [CanBeNull] string tablePrefix = AbpIdentityServerConsts.DefaultDbTablePrefix, - [CanBeNull] string schema = AbpIdentityServerConsts.DefaultDbSchema) + this ModelBuilder builder, + Action optionsAction = null) { Check.NotNull(builder, nameof(builder)); - if (tablePrefix == null) - { - tablePrefix = ""; - } + var options = new IdentityServerModelBuilderConfigurationOptions( + AbpIdentityServerDbProperties.DbTablePrefix, + AbpIdentityServerDbProperties.DbSchema + ); + + optionsAction?.Invoke(options); builder.Entity(client => { - client.ToTable(tablePrefix + "Clients", schema); + client.ToTable(options.TablePrefix + "Clients", options.Schema); client.ConfigureFullAuditedAggregateRoot(); @@ -57,7 +58,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore builder.Entity(grantType => { - grantType.ToTable(tablePrefix + "ClientGrantTypes", schema); + grantType.ToTable(options.TablePrefix + "ClientGrantTypes", options.Schema); grantType.HasKey(x => new { x.ClientId, x.GrantType }); @@ -66,7 +67,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore builder.Entity(redirectUri => { - redirectUri.ToTable(tablePrefix + "ClientRedirectUris", schema); + redirectUri.ToTable(options.TablePrefix + "ClientRedirectUris", options.Schema); redirectUri.HasKey(x => new { x.ClientId, x.RedirectUri }); @@ -75,7 +76,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore builder.Entity(postLogoutRedirectUri => { - postLogoutRedirectUri.ToTable(tablePrefix + "ClientPostLogoutRedirectUris", schema); + postLogoutRedirectUri.ToTable(options.TablePrefix + "ClientPostLogoutRedirectUris", options.Schema); postLogoutRedirectUri.HasKey(x => new { x.ClientId, x.PostLogoutRedirectUri }); @@ -84,7 +85,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore builder.Entity(scope => { - scope.ToTable(tablePrefix + "ClientScopes", schema); + scope.ToTable(options.TablePrefix + "ClientScopes", options.Schema); scope.HasKey(x => new { x.ClientId, x.Scope }); @@ -93,7 +94,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore builder.Entity(secret => { - secret.ToTable(tablePrefix + "ClientSecrets", schema); + secret.ToTable(options.TablePrefix + "ClientSecrets", options.Schema); secret.HasKey(x => new { x.ClientId, x.Type, x.Value }); @@ -104,7 +105,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore builder.Entity(claim => { - claim.ToTable(tablePrefix + "ClientClaims", schema); + claim.ToTable(options.TablePrefix + "ClientClaims", options.Schema); claim.HasKey(x => new { x.ClientId, x.Type, x.Value }); @@ -114,7 +115,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore builder.Entity(idPRestriction => { - idPRestriction.ToTable(tablePrefix + "ClientIdPRestrictions", schema); + idPRestriction.ToTable(options.TablePrefix + "ClientIdPRestrictions", options.Schema); idPRestriction.HasKey(x => new { x.ClientId, x.Provider }); @@ -123,7 +124,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore builder.Entity(corsOrigin => { - corsOrigin.ToTable(tablePrefix + "ClientCorsOrigins", schema); + corsOrigin.ToTable(options.TablePrefix + "ClientCorsOrigins", options.Schema); corsOrigin.HasKey(x => new { x.ClientId, x.Origin }); @@ -132,7 +133,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore builder.Entity(property => { - property.ToTable(tablePrefix + "ClientProperties", schema); + property.ToTable(options.TablePrefix + "ClientProperties", options.Schema); property.HasKey(x => new { x.ClientId, x.Key }); @@ -142,7 +143,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore builder.Entity(grant => { - grant.ToTable(tablePrefix + "PersistedGrants", schema); + grant.ToTable(options.TablePrefix + "PersistedGrants", options.Schema); grant.ConfigureExtraProperties(); @@ -161,7 +162,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore builder.Entity(identityResource => { - identityResource.ToTable(tablePrefix + "IdentityResources", schema); + identityResource.ToTable(options.TablePrefix + "IdentityResources", options.Schema); identityResource.ConfigureFullAuditedAggregateRoot(); @@ -179,7 +180,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore builder.Entity(claim => { - claim.ToTable(tablePrefix + "IdentityClaims", schema); + claim.ToTable(options.TablePrefix + "IdentityClaims", options.Schema); claim.HasKey(x => new { x.IdentityResourceId, x.Type }); @@ -188,7 +189,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore builder.Entity(apiResource => { - apiResource.ToTable(tablePrefix + "ApiResources", schema); + apiResource.ToTable(options.TablePrefix + "ApiResources", options.Schema); apiResource.ConfigureFullAuditedAggregateRoot(); @@ -208,7 +209,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore builder.Entity(apiSecret => { - apiSecret.ToTable(tablePrefix + "ApiSecrets", schema); + apiSecret.ToTable(options.TablePrefix + "ApiSecrets", options.Schema); apiSecret.HasKey(x => new { x.ApiResourceId, x.Type, x.Value }); @@ -219,7 +220,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore builder.Entity(apiClaim => { - apiClaim.ToTable(tablePrefix + "ApiClaims", schema); + apiClaim.ToTable(options.TablePrefix + "ApiClaims", options.Schema); apiClaim.HasKey(x => new { x.ApiResourceId, x.Type }); @@ -228,7 +229,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore builder.Entity(apiScope => { - apiScope.ToTable(tablePrefix + "ApiScopes", schema); + apiScope.ToTable(options.TablePrefix + "ApiScopes", options.Schema); apiScope.HasKey(x => new { x.ApiResourceId, x.Name }); @@ -241,7 +242,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore builder.Entity(apiScopeClaim => { - apiScopeClaim.ToTable(tablePrefix + "ApiScopeClaims", schema); + apiScopeClaim.ToTable(options.TablePrefix + "ApiScopeClaims", options.Schema); apiScopeClaim.HasKey(x => new { x.ApiResourceId, x.Name, x.Type }); diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerModelBuilderConfigurationOptions.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerModelBuilderConfigurationOptions.cs new file mode 100644 index 0000000000..55dcc06837 --- /dev/null +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerModelBuilderConfigurationOptions.cs @@ -0,0 +1,18 @@ +using JetBrains.Annotations; +using Volo.Abp.EntityFrameworkCore.Modeling; + +namespace Volo.Abp.IdentityServer.EntityFrameworkCore +{ + public class IdentityServerModelBuilderConfigurationOptions : ModelBuilderConfigurationOptions + { + public IdentityServerModelBuilderConfigurationOptions( + [NotNull] string tablePrefix, + [CanBeNull] string schema) + : base( + tablePrefix, + schema) + { + + } + } +} \ No newline at end of file diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/AbpIdentityServerMongoDbContext.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/AbpIdentityServerMongoDbContext.cs index 7f519234a0..16f99b9119 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/AbpIdentityServerMongoDbContext.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/AbpIdentityServerMongoDbContext.cs @@ -8,11 +8,9 @@ using IdentityResource = Volo.Abp.IdentityServer.IdentityResources.IdentityResou namespace Volo.Abp.IdentityServer.MongoDB { - [ConnectionStringName(AbpIdentityServerConsts.ConnectionStringName)] + [ConnectionStringName(AbpIdentityServerDbProperties.ConnectionStringName)] public class AbpIdentityServerMongoDbContext : AbpMongoDbContext, IAbpIdentityServerMongoDbContext { - public static string CollectionPrefix { get; set; } = AbpIdentityServerConsts.DefaultDbTablePrefix; - public IMongoCollection ApiResources => Collection(); public IMongoCollection Clients => Collection(); @@ -25,10 +23,7 @@ namespace Volo.Abp.IdentityServer.MongoDB { base.CreateModel(modelBuilder); - modelBuilder.ConfigureIdentityServer(options => - { - options.CollectionPrefix = CollectionPrefix; - }); + modelBuilder.ConfigureIdentityServer(); } } } diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/AbpIdentityServerMongoDbContextExtensions.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/AbpIdentityServerMongoDbContextExtensions.cs index 6f81a67493..474188a0e1 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/AbpIdentityServerMongoDbContextExtensions.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/AbpIdentityServerMongoDbContextExtensions.cs @@ -15,7 +15,9 @@ namespace Volo.Abp.IdentityServer.MongoDB { Check.NotNull(builder, nameof(builder)); - var options = new IdentityServerMongoModelBuilderConfigurationOptions(); + var options = new IdentityServerMongoModelBuilderConfigurationOptions( + AbpIdentityServerDbProperties.DbTablePrefix + ); optionsAction?.Invoke(options); diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/IAbpIdentityServerMongoDbContext.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/IAbpIdentityServerMongoDbContext.cs index 2813c4f87b..cda4718896 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/IAbpIdentityServerMongoDbContext.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/IAbpIdentityServerMongoDbContext.cs @@ -8,7 +8,7 @@ using ApiResource = Volo.Abp.IdentityServer.ApiResources.ApiResource; namespace Volo.Abp.IdentityServer.MongoDB { - [ConnectionStringName(AbpIdentityServerConsts.ConnectionStringName)] + [ConnectionStringName(AbpIdentityServerDbProperties.ConnectionStringName)] public interface IAbpIdentityServerMongoDbContext : IAbpMongoDbContext { IMongoCollection ApiResources { get; } diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/IdentityServerMongoModelBuilderConfigurationOptions.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/IdentityServerMongoModelBuilderConfigurationOptions.cs index bb88711e9e..f6afe62737 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/IdentityServerMongoModelBuilderConfigurationOptions.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/IdentityServerMongoModelBuilderConfigurationOptions.cs @@ -1,11 +1,12 @@ -using Volo.Abp.MongoDB; +using JetBrains.Annotations; +using Volo.Abp.MongoDB; namespace Volo.Abp.IdentityServer.MongoDB { public class IdentityServerMongoModelBuilderConfigurationOptions : MongoModelBuilderConfigurationOptions { - public IdentityServerMongoModelBuilderConfigurationOptions() - : base(AbpIdentityServerConsts.DefaultDbTablePrefix) + public IdentityServerMongoModelBuilderConfigurationOptions([NotNull] string collectionPrefix = "") + : base(collectionPrefix) { } }