From a003d63e1d4e56c1cb74a0cb5d2b32ec8db707f5 Mon Sep 17 00:00:00 2001 From: Alper Ebicoglu Date: Mon, 8 Jan 2018 16:35:43 +0300 Subject: [PATCH 1/3] Added IdentityServerDbContext --- .../IdentityServerDbContext.cs | 215 +++++++++++++++++- 1 file changed, 213 insertions(+), 2 deletions(-) diff --git a/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContext.cs b/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContext.cs index 3c4bc19fc4..84c7311b84 100644 --- a/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContext.cs +++ b/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContext.cs @@ -9,6 +9,8 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore { public class IdentityServerDbContext : AbpDbContext { + public const string TablePrefix = "AbpIds"; + public DbSet Clients { get; set; } public DbSet PersistedGrants { get; set; } @@ -17,12 +19,221 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore public DbSet IdentityResources { get; set; } - //TODO: Add child entity types too... + 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 IdentityServerDbContext(DbContextOptions options) + public DbSet ClientCorsOrigins { get; set; } + + public DbSet ClientProperties { get; set; } + + public DbSet IdentityClaims { get; set; } + + public DbSet ApiSecrets { get; set; } + + public DbSet ApiResourceClaims { get; set; } + + public DbSet ApiScopes { get; set; } + + public DbSet ApiScopeClaims { get; set; } + + public IdentityServerDbContext(DbContextOptions options) : base(options) { } + + protected override void OnModelCreating(ModelBuilder builder) + { + base.OnModelCreating(builder); + + builder.Entity(client => + { + client.ToTable(TablePrefix + "Clients"); + + client.HasKey(x => x.Id); + + client.Property(x => x.ClientId).HasMaxLength(200).IsRequired(); + client.Property(x => x.ProtocolType).HasMaxLength(200).IsRequired(); + client.Property(x => x.ClientName).HasMaxLength(200); + client.Property(x => x.ClientUri).HasMaxLength(2000); + client.Property(x => x.LogoUri).HasMaxLength(2000); + client.Property(x => x.Description).HasMaxLength(1000); + client.Property(x => x.FrontChannelLogoutUri).HasMaxLength(2000); + client.Property(x => x.BackChannelLogoutUri).HasMaxLength(2000); + client.Property(x => x.ClientClaimsPrefix).HasMaxLength(200); + client.Property(x => x.PairWiseSubjectSalt).HasMaxLength(200); + + client.HasMany(x => x.AllowedGrantTypes).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); + client.HasMany(x => x.RedirectUris).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); + client.HasMany(x => x.PostLogoutRedirectUris).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); + client.HasMany(x => x.AllowedScopes).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); + client.HasMany(x => x.ClientSecrets).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); + client.HasMany(x => x.Claims).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); + client.HasMany(x => x.IdentityProviderRestrictions).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); + client.HasMany(x => x.AllowedCorsOrigins).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); + client.HasMany(x => x.Properties).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); + + client.HasIndex(x => x.ClientId).IsUnique(); + }); + + builder.Entity(grantType => + { + grantType.ToTable(TablePrefix + "ClientGrantTypes"); + grantType.Property(x => x.GrantType).HasMaxLength(250).IsRequired(); + + grantType.Property(x => x.ClientId).IsRequired(); + }); + + builder.Entity(redirectUri => + { + redirectUri.ToTable(TablePrefix + "ClientRedirectUris"); + redirectUri.Property(x => x.RedirectUri).HasMaxLength(2000).IsRequired(); + }); + + builder.Entity(postLogoutRedirectUri => + { + postLogoutRedirectUri.ToTable(TablePrefix + "ClientPostLogoutRedirectUris"); + postLogoutRedirectUri.Property(x => x.PostLogoutRedirectUri).HasMaxLength(2000).IsRequired(); + }); + + builder.Entity(scope => + { + scope.ToTable(TablePrefix + "ClientScopes"); + scope.Property(x => x.Scope).HasMaxLength(200).IsRequired(); + }); + + builder.Entity(secret => + { + secret.ToTable(TablePrefix + "ClientSecrets"); + secret.Property(x => x.Value).HasMaxLength(2000).IsRequired(); + secret.Property(x => x.Type).HasMaxLength(250); + secret.Property(x => x.Description).HasMaxLength(2000); + }); + + builder.Entity(claim => + { + claim.ToTable(TablePrefix + "ClientClaims"); + claim.Property(x => x.Type).HasMaxLength(250).IsRequired(); + claim.Property(x => x.Value).HasMaxLength(250).IsRequired(); + }); + + builder.Entity(idPRestriction => + { + idPRestriction.ToTable(TablePrefix + "ClientIdPRestrictions"); + idPRestriction.Property(x => x.Provider).HasMaxLength(200).IsRequired(); + }); + + builder.Entity(corsOrigin => + { + corsOrigin.ToTable(TablePrefix + "ClientCorsOrigins"); + corsOrigin.Property(x => x.Origin).HasMaxLength(150).IsRequired(); + }); + + builder.Entity(property => + { + property.ToTable(TablePrefix + "ClientProperties"); + property.Property(x => x.Key).HasMaxLength(250).IsRequired(); + property.Property(x => x.Value).HasMaxLength(2000).IsRequired(); + }); + + builder.Entity(grant => + { + grant.ToTable(TablePrefix + "PersistedGrants"); + + grant.Property(x => x.Key).HasMaxLength(200).ValueGeneratedNever(); + grant.Property(x => x.Type).HasMaxLength(50).IsRequired(); + grant.Property(x => x.SubjectId).HasMaxLength(200); + grant.Property(x => x.ClientId).HasMaxLength(200).IsRequired(); + grant.Property(x => x.CreationTime).IsRequired(); + grant.Property(x => x.Data).IsRequired(); + + grant.HasKey(x => x.Key); + + grant.HasIndex(x => new { x.SubjectId, x.ClientId, x.Type }); + }); + + builder.Entity(identityResource => + { + identityResource.ToTable(TablePrefix + "IdentityResources").HasKey(x => x.Id); + + identityResource.Property(x => x.Name).HasMaxLength(200).IsRequired(); + identityResource.Property(x => x.DisplayName).HasMaxLength(200); + identityResource.Property(x => x.Description).HasMaxLength(1000); + + identityResource.HasIndex(x => x.Name).IsUnique(); + + + identityResource.HasMany(x => x.UserClaims).WithOne().HasForeignKey(x => x.IdentityResourceId).IsRequired(); + }); + + builder.Entity(claim => + { + claim.ToTable(TablePrefix + "IdentityClaims").HasKey(x => x.Id); + + claim.Property(x => x.Type).HasMaxLength(200).IsRequired(); + }); + + builder.Entity(apiResource => + { + apiResource.ToTable(TablePrefix + "ApiResources").HasKey(x => x.Id); + + apiResource.Property(x => x.Name).HasMaxLength(200).IsRequired(); + apiResource.Property(x => x.DisplayName).HasMaxLength(200); + apiResource.Property(x => x.Description).HasMaxLength(1000); + + apiResource.HasIndex(x => x.Name).IsUnique(); + + apiResource.HasMany(x => x.Secrets).WithOne().HasForeignKey(x => x.ApiResourceId).IsRequired(); + apiResource.HasMany(x => x.Scopes).WithOne().HasForeignKey(x => x.ApiResourceId).IsRequired(); + apiResource.HasMany(x => x.UserClaims).WithOne().HasForeignKey(x => x.ApiResourceId).IsRequired(); + }); + + builder.Entity(apiSecret => + { + apiSecret.ToTable(TablePrefix + "ApiSecrets").HasKey(x => x.Id); + + apiSecret.Property(x => x.Description).HasMaxLength(1000); + apiSecret.Property(x => x.Value).HasMaxLength(2000); + apiSecret.Property(x => x.Type).HasMaxLength(250); + }); + + builder.Entity(apiClaim => + { + apiClaim.ToTable(TablePrefix + "ApiClaims").HasKey(x => x.Id); + + apiClaim.Property(x => x.Type).HasMaxLength(200).IsRequired(); + }); + + builder.Entity(apiScope => + { + apiScope.ToTable(TablePrefix + "ApiScopes").HasKey(x => x.Id); + + apiScope.Property(x => x.Name).HasMaxLength(200).IsRequired(); + apiScope.Property(x => x.DisplayName).HasMaxLength(200); + apiScope.Property(x => x.Description).HasMaxLength(1000); + + apiScope.HasIndex(x => x.Name).IsUnique(); + + apiScope.HasMany(x => x.UserClaims).WithOne().HasForeignKey(x => x.ApiScopeId).IsRequired(); + }); + + builder.Entity(apiScopeClaim => + { + apiScopeClaim.ToTable(TablePrefix + "ApiScopeClaims").HasKey(x => x.Id); + + apiScopeClaim.Property(x => x.Type).HasMaxLength(200).IsRequired(); + }); + } } } From b7185c1be5dfc04a67be0346fd17a1fe44d812ca Mon Sep 17 00:00:00 2001 From: Alper Ebicoglu Date: Mon, 8 Jan 2018 17:27:01 +0300 Subject: [PATCH 2/3] Added max lengths for Identity server entities --- .../ApiResources/ApiResourceClaimConsts.cs | 7 ++ .../ApiResources/ApiResourceConsts.cs | 9 ++ .../ApiResources/ApiScopeClaimConsts.cs | 7 ++ .../ApiResources/ApiScopeConsts.cs | 9 ++ .../ApiResources/ApiSecretConsts.cs | 9 ++ .../Clients/ClientClaimConsts.cs | 8 ++ .../IdentityServer/Clients/ClientConsts.cs | 25 ++++++ .../Clients/ClientCorsOriginConsts.cs | 7 ++ .../Clients/ClientGrantTypeConsts.cs | 7 ++ .../Clients/ClientIdPRestrictionConsts.cs | 7 ++ .../ClientPostLogoutRedirectUriConsts.cs | 7 ++ .../Clients/ClientPropertyConsts.cs | 8 ++ .../Clients/ClientRedirectUriConsts.cs | 7 ++ .../Clients/ClientScopeConsts.cs | 7 ++ .../Clients/ClientSecretConsts.cs | 9 ++ .../Grants/PersistedGrantConsts.cs | 10 +++ .../IdentityResources/IdentityClaimConsts.cs | 7 ++ .../IdentityResourceConsts.cs | 9 ++ .../IdentityServerDbContext.cs | 84 +++++++++---------- 19 files changed, 201 insertions(+), 42 deletions(-) create mode 100644 src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResourceClaimConsts.cs create mode 100644 src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResourceConsts.cs create mode 100644 src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScopeClaimConsts.cs create mode 100644 src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScopeConsts.cs create mode 100644 src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiSecretConsts.cs create mode 100644 src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientClaimConsts.cs create mode 100644 src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientConsts.cs create mode 100644 src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientCorsOriginConsts.cs create mode 100644 src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientGrantTypeConsts.cs create mode 100644 src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientIdPRestrictionConsts.cs create mode 100644 src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientPostLogoutRedirectUriConsts.cs create mode 100644 src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientPropertyConsts.cs create mode 100644 src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientRedirectUriConsts.cs create mode 100644 src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientScopeConsts.cs create mode 100644 src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientSecretConsts.cs create mode 100644 src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Grants/PersistedGrantConsts.cs create mode 100644 src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityClaimConsts.cs create mode 100644 src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceConsts.cs diff --git a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResourceClaimConsts.cs b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResourceClaimConsts.cs new file mode 100644 index 0000000000..a87d3566fc --- /dev/null +++ b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResourceClaimConsts.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.IdentityServer.ApiResources +{ + public class ApiResourceClaimConsts + { + public const int TypeMaxLength = 200; + } +} \ No newline at end of file diff --git a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResourceConsts.cs b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResourceConsts.cs new file mode 100644 index 0000000000..1c3aecc531 --- /dev/null +++ b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResourceConsts.cs @@ -0,0 +1,9 @@ +namespace Volo.Abp.IdentityServer.ApiResources +{ + public class ApiResourceConsts + { + public const int NameMaxLength = 200; + public const int DisplayNameMaxLength = 200; + public const int DescriptionMaxLength = 1000; + } +} \ No newline at end of file diff --git a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScopeClaimConsts.cs b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScopeClaimConsts.cs new file mode 100644 index 0000000000..5e06a29402 --- /dev/null +++ b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScopeClaimConsts.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.IdentityServer.ApiResources +{ + public class ApiScopeClaimConsts + { + public const int TypeMaxLength = 200; + } +} \ No newline at end of file diff --git a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScopeConsts.cs b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScopeConsts.cs new file mode 100644 index 0000000000..d52b953921 --- /dev/null +++ b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScopeConsts.cs @@ -0,0 +1,9 @@ +namespace Volo.Abp.IdentityServer.ApiResources +{ + public class ApiScopeConsts + { + public const int NameMaxLength = 200; + public const int DisplayNameMaxLength = 200; + public const int DescriptionMaxLength = 1000; + } +} \ No newline at end of file diff --git a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiSecretConsts.cs b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiSecretConsts.cs new file mode 100644 index 0000000000..5008a34afb --- /dev/null +++ b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiSecretConsts.cs @@ -0,0 +1,9 @@ +namespace Volo.Abp.IdentityServer.ApiResources +{ + public class ApiSecretConsts + { + public const int DescriptionMaxLength = 1000; + public const int ValueMaxLength = 2000; + public const int TypeMaxLength = 250; + } +} \ No newline at end of file diff --git a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientClaimConsts.cs b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientClaimConsts.cs new file mode 100644 index 0000000000..3a5d1fe907 --- /dev/null +++ b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientClaimConsts.cs @@ -0,0 +1,8 @@ +namespace Volo.Abp.IdentityServer.Clients +{ + public class ClientClaimConsts + { + public const int TypeMaxLength = 250; + public const int ValueMaxLength = 250; + } +} \ No newline at end of file diff --git a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientConsts.cs b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientConsts.cs new file mode 100644 index 0000000000..d83138fd2f --- /dev/null +++ b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientConsts.cs @@ -0,0 +1,25 @@ +namespace Volo.Abp.IdentityServer.Clients +{ + public class ClientConsts + { + public const int ClientIdMaxLength = 200; + + public const int ProtocolTypeMaxLength = 200; + + public const int ClientNameMaxLength = 200; + + public const int ClientUriMaxLength = 2000; + + public const int LogoUriMaxLength = 2000; + + public const int DescriptionMaxLength = 1000; + + public const int FrontChannelLogoutUriMaxLength = 2000; + + public const int BackChannelLogoutUriMaxLength = 2000; + + public const int ClientClaimsPrefixMaxLength = 200; + + public const int PairWiseSubjectSaltMaxLength = 200; + } +} \ No newline at end of file diff --git a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientCorsOriginConsts.cs b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientCorsOriginConsts.cs new file mode 100644 index 0000000000..07ba598d6c --- /dev/null +++ b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientCorsOriginConsts.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.IdentityServer.Clients +{ + public class ClientCorsOriginConsts + { + public const int OriginMaxLength = 150; + } +} \ No newline at end of file diff --git a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientGrantTypeConsts.cs b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientGrantTypeConsts.cs new file mode 100644 index 0000000000..5f94c51f97 --- /dev/null +++ b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientGrantTypeConsts.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.IdentityServer.Clients +{ + public class ClientGrantTypeConsts + { + public const int GrantTypeMaxLength = 250; + } +} \ No newline at end of file diff --git a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientIdPRestrictionConsts.cs b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientIdPRestrictionConsts.cs new file mode 100644 index 0000000000..c71301871a --- /dev/null +++ b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientIdPRestrictionConsts.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.IdentityServer.Clients +{ + public class ClientIdPRestrictionConsts + { + public const int ProviderMaxLength = 200; + } +} \ No newline at end of file diff --git a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientPostLogoutRedirectUriConsts.cs b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientPostLogoutRedirectUriConsts.cs new file mode 100644 index 0000000000..8fe55ba018 --- /dev/null +++ b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientPostLogoutRedirectUriConsts.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.IdentityServer.Clients +{ + public class ClientPostLogoutRedirectUriConsts + { + public const int PostLogoutRedirectUriMaxLength = 2000; + } +} \ No newline at end of file diff --git a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientPropertyConsts.cs b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientPropertyConsts.cs new file mode 100644 index 0000000000..6535304596 --- /dev/null +++ b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientPropertyConsts.cs @@ -0,0 +1,8 @@ +namespace Volo.Abp.IdentityServer.Clients +{ + public class ClientPropertyConsts + { + public const int KeyMaxLength = 250; + public const int ValueMaxLength = 2000; + } +} \ No newline at end of file diff --git a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientRedirectUriConsts.cs b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientRedirectUriConsts.cs new file mode 100644 index 0000000000..d67bbea509 --- /dev/null +++ b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientRedirectUriConsts.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.IdentityServer.Clients +{ + public class ClientRedirectUriConsts + { + public const int RedirectUriMaxLength = 2000; + } +} \ No newline at end of file diff --git a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientScopeConsts.cs b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientScopeConsts.cs new file mode 100644 index 0000000000..6a5b62e692 --- /dev/null +++ b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientScopeConsts.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.IdentityServer.Clients +{ + public class ClientScopeConsts + { + public const int ScopeMaxLength = 200; + } +} \ No newline at end of file diff --git a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientSecretConsts.cs b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientSecretConsts.cs new file mode 100644 index 0000000000..f3e47a5973 --- /dev/null +++ b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientSecretConsts.cs @@ -0,0 +1,9 @@ +namespace Volo.Abp.IdentityServer.Clients +{ + public class ClientSecretConsts + { + public const int ValueMaxLength = 2000; + public const int TypeMaxLength = 250; + public const int DescriptionMaxLength = 2000; + } +} \ No newline at end of file diff --git a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Grants/PersistedGrantConsts.cs b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Grants/PersistedGrantConsts.cs new file mode 100644 index 0000000000..75f67dcc3a --- /dev/null +++ b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Grants/PersistedGrantConsts.cs @@ -0,0 +1,10 @@ +namespace Volo.Abp.IdentityServer.Grants +{ + public class PersistedGrantConsts + { + public const int KeyMaxLength = 200; + public const int TypeMaxLength = 50; + public const int SubjectIdMaxLength = 200; + public const int ClientIdMaxLength = 200; + } +} \ No newline at end of file diff --git a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityClaimConsts.cs b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityClaimConsts.cs new file mode 100644 index 0000000000..5a0ee5e177 --- /dev/null +++ b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityClaimConsts.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.IdentityServer.IdentityResources +{ + public class IdentityClaimConsts + { + public const int TypeMaxLength = 200; + } +} \ No newline at end of file diff --git a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceConsts.cs b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceConsts.cs new file mode 100644 index 0000000000..c60cc34ad8 --- /dev/null +++ b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceConsts.cs @@ -0,0 +1,9 @@ +namespace Volo.Abp.IdentityServer.IdentityResources +{ + public class IdentityResourceConsts + { + public const int NameMaxLength = 200; + public const int DisplayNameMaxLength = 200; + public const int DescriptionMaxLength = 1000; + } +} \ No newline at end of file diff --git a/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContext.cs b/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContext.cs index 84c7311b84..d56db360f0 100644 --- a/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContext.cs +++ b/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContext.cs @@ -63,16 +63,16 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore client.HasKey(x => x.Id); - client.Property(x => x.ClientId).HasMaxLength(200).IsRequired(); - client.Property(x => x.ProtocolType).HasMaxLength(200).IsRequired(); - client.Property(x => x.ClientName).HasMaxLength(200); - client.Property(x => x.ClientUri).HasMaxLength(2000); - client.Property(x => x.LogoUri).HasMaxLength(2000); - client.Property(x => x.Description).HasMaxLength(1000); - client.Property(x => x.FrontChannelLogoutUri).HasMaxLength(2000); - client.Property(x => x.BackChannelLogoutUri).HasMaxLength(2000); - client.Property(x => x.ClientClaimsPrefix).HasMaxLength(200); - client.Property(x => x.PairWiseSubjectSalt).HasMaxLength(200); + client.Property(x => x.ClientId).HasMaxLength(ClientConsts.ClientIdMaxLength).IsRequired(); + client.Property(x => x.ProtocolType).HasMaxLength(ClientConsts.ProtocolTypeMaxLength).IsRequired(); + client.Property(x => x.ClientName).HasMaxLength(ClientConsts.ClientNameMaxLength); + client.Property(x => x.ClientUri).HasMaxLength(ClientConsts.ClientUriMaxLength); + client.Property(x => x.LogoUri).HasMaxLength(ClientConsts.LogoUriMaxLength); + client.Property(x => x.Description).HasMaxLength(ClientConsts.DescriptionMaxLength); + client.Property(x => x.FrontChannelLogoutUri).HasMaxLength(ClientConsts.FrontChannelLogoutUriMaxLength); + client.Property(x => x.BackChannelLogoutUri).HasMaxLength(ClientConsts.BackChannelLogoutUriMaxLength); + client.Property(x => x.ClientClaimsPrefix).HasMaxLength(ClientConsts.ClientClaimsPrefixMaxLength); + client.Property(x => x.PairWiseSubjectSalt).HasMaxLength(ClientConsts.PairWiseSubjectSaltMaxLength); client.HasMany(x => x.AllowedGrantTypes).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); client.HasMany(x => x.RedirectUris).WithOne().HasForeignKey(x => x.ClientId).IsRequired(); @@ -90,7 +90,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore builder.Entity(grantType => { grantType.ToTable(TablePrefix + "ClientGrantTypes"); - grantType.Property(x => x.GrantType).HasMaxLength(250).IsRequired(); + grantType.Property(x => x.GrantType).HasMaxLength(ClientGrantTypeConsts.GrantTypeMaxLength).IsRequired(); grantType.Property(x => x.ClientId).IsRequired(); }); @@ -98,63 +98,63 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore builder.Entity(redirectUri => { redirectUri.ToTable(TablePrefix + "ClientRedirectUris"); - redirectUri.Property(x => x.RedirectUri).HasMaxLength(2000).IsRequired(); + redirectUri.Property(x => x.RedirectUri).HasMaxLength(ClientRedirectUriConsts.RedirectUriMaxLength).IsRequired(); }); builder.Entity(postLogoutRedirectUri => { postLogoutRedirectUri.ToTable(TablePrefix + "ClientPostLogoutRedirectUris"); - postLogoutRedirectUri.Property(x => x.PostLogoutRedirectUri).HasMaxLength(2000).IsRequired(); + postLogoutRedirectUri.Property(x => x.PostLogoutRedirectUri).HasMaxLength(ClientPostLogoutRedirectUriConsts.PostLogoutRedirectUriMaxLength).IsRequired(); }); builder.Entity(scope => { scope.ToTable(TablePrefix + "ClientScopes"); - scope.Property(x => x.Scope).HasMaxLength(200).IsRequired(); + scope.Property(x => x.Scope).HasMaxLength(ClientScopeConsts.ScopeMaxLength).IsRequired(); }); builder.Entity(secret => { secret.ToTable(TablePrefix + "ClientSecrets"); - secret.Property(x => x.Value).HasMaxLength(2000).IsRequired(); - secret.Property(x => x.Type).HasMaxLength(250); - secret.Property(x => x.Description).HasMaxLength(2000); + secret.Property(x => x.Value).HasMaxLength(ClientSecretConsts.ValueMaxLength).IsRequired(); + secret.Property(x => x.Type).HasMaxLength(ClientSecretConsts.TypeMaxLength); + secret.Property(x => x.Description).HasMaxLength(ClientSecretConsts.DescriptionMaxLength); }); builder.Entity(claim => { claim.ToTable(TablePrefix + "ClientClaims"); - claim.Property(x => x.Type).HasMaxLength(250).IsRequired(); - claim.Property(x => x.Value).HasMaxLength(250).IsRequired(); + claim.Property(x => x.Type).HasMaxLength(ClientClaimConsts.TypeMaxLength).IsRequired(); + claim.Property(x => x.Value).HasMaxLength(ClientClaimConsts.ValueMaxLength).IsRequired(); }); builder.Entity(idPRestriction => { idPRestriction.ToTable(TablePrefix + "ClientIdPRestrictions"); - idPRestriction.Property(x => x.Provider).HasMaxLength(200).IsRequired(); + idPRestriction.Property(x => x.Provider).HasMaxLength(ClientIdPRestrictionConsts.ProviderMaxLength).IsRequired(); }); builder.Entity(corsOrigin => { corsOrigin.ToTable(TablePrefix + "ClientCorsOrigins"); - corsOrigin.Property(x => x.Origin).HasMaxLength(150).IsRequired(); + corsOrigin.Property(x => x.Origin).HasMaxLength(ClientCorsOriginConsts.OriginMaxLength).IsRequired(); }); builder.Entity(property => { property.ToTable(TablePrefix + "ClientProperties"); - property.Property(x => x.Key).HasMaxLength(250).IsRequired(); - property.Property(x => x.Value).HasMaxLength(2000).IsRequired(); + property.Property(x => x.Key).HasMaxLength(ClientPropertyConsts.KeyMaxLength).IsRequired(); + property.Property(x => x.Value).HasMaxLength(ClientPropertyConsts.ValueMaxLength).IsRequired(); }); builder.Entity(grant => { grant.ToTable(TablePrefix + "PersistedGrants"); - grant.Property(x => x.Key).HasMaxLength(200).ValueGeneratedNever(); - grant.Property(x => x.Type).HasMaxLength(50).IsRequired(); - grant.Property(x => x.SubjectId).HasMaxLength(200); - grant.Property(x => x.ClientId).HasMaxLength(200).IsRequired(); + grant.Property(x => x.Key).HasMaxLength(PersistedGrantConsts.KeyMaxLength).ValueGeneratedNever(); + grant.Property(x => x.Type).HasMaxLength(PersistedGrantConsts.TypeMaxLength).IsRequired(); + grant.Property(x => x.SubjectId).HasMaxLength(PersistedGrantConsts.SubjectIdMaxLength); + grant.Property(x => x.ClientId).HasMaxLength(PersistedGrantConsts.ClientIdMaxLength).IsRequired(); grant.Property(x => x.CreationTime).IsRequired(); grant.Property(x => x.Data).IsRequired(); @@ -167,9 +167,9 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore { identityResource.ToTable(TablePrefix + "IdentityResources").HasKey(x => x.Id); - identityResource.Property(x => x.Name).HasMaxLength(200).IsRequired(); - identityResource.Property(x => x.DisplayName).HasMaxLength(200); - identityResource.Property(x => x.Description).HasMaxLength(1000); + identityResource.Property(x => x.Name).HasMaxLength(IdentityResourceConsts.NameMaxLength).IsRequired(); + identityResource.Property(x => x.DisplayName).HasMaxLength(IdentityResourceConsts.DisplayNameMaxLength); + identityResource.Property(x => x.Description).HasMaxLength(IdentityResourceConsts.DescriptionMaxLength); identityResource.HasIndex(x => x.Name).IsUnique(); @@ -181,16 +181,16 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore { claim.ToTable(TablePrefix + "IdentityClaims").HasKey(x => x.Id); - claim.Property(x => x.Type).HasMaxLength(200).IsRequired(); + claim.Property(x => x.Type).HasMaxLength(IdentityClaimConsts.TypeMaxLength).IsRequired(); }); builder.Entity(apiResource => { apiResource.ToTable(TablePrefix + "ApiResources").HasKey(x => x.Id); - apiResource.Property(x => x.Name).HasMaxLength(200).IsRequired(); - apiResource.Property(x => x.DisplayName).HasMaxLength(200); - apiResource.Property(x => x.Description).HasMaxLength(1000); + apiResource.Property(x => x.Name).HasMaxLength(ApiResourceConsts.NameMaxLength).IsRequired(); + apiResource.Property(x => x.DisplayName).HasMaxLength(ApiResourceConsts.DisplayNameMaxLength); + apiResource.Property(x => x.Description).HasMaxLength(ApiResourceConsts.DescriptionMaxLength); apiResource.HasIndex(x => x.Name).IsUnique(); @@ -203,25 +203,25 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore { apiSecret.ToTable(TablePrefix + "ApiSecrets").HasKey(x => x.Id); - apiSecret.Property(x => x.Description).HasMaxLength(1000); - apiSecret.Property(x => x.Value).HasMaxLength(2000); - apiSecret.Property(x => x.Type).HasMaxLength(250); + apiSecret.Property(x => x.Description).HasMaxLength(ApiSecretConsts.DescriptionMaxLength); + apiSecret.Property(x => x.Value).HasMaxLength(ApiSecretConsts.ValueMaxLength); + apiSecret.Property(x => x.Type).HasMaxLength(ApiSecretConsts.TypeMaxLength); }); builder.Entity(apiClaim => { apiClaim.ToTable(TablePrefix + "ApiClaims").HasKey(x => x.Id); - apiClaim.Property(x => x.Type).HasMaxLength(200).IsRequired(); + apiClaim.Property(x => x.Type).HasMaxLength(ApiResourceClaimConsts.TypeMaxLength).IsRequired(); }); builder.Entity(apiScope => { apiScope.ToTable(TablePrefix + "ApiScopes").HasKey(x => x.Id); - apiScope.Property(x => x.Name).HasMaxLength(200).IsRequired(); - apiScope.Property(x => x.DisplayName).HasMaxLength(200); - apiScope.Property(x => x.Description).HasMaxLength(1000); + apiScope.Property(x => x.Name).HasMaxLength(ApiScopeConsts.NameMaxLength).IsRequired(); + apiScope.Property(x => x.DisplayName).HasMaxLength(ApiScopeConsts.DisplayNameMaxLength); + apiScope.Property(x => x.Description).HasMaxLength(ApiScopeConsts.DescriptionMaxLength); apiScope.HasIndex(x => x.Name).IsUnique(); @@ -232,7 +232,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore { apiScopeClaim.ToTable(TablePrefix + "ApiScopeClaims").HasKey(x => x.Id); - apiScopeClaim.Property(x => x.Type).HasMaxLength(200).IsRequired(); + apiScopeClaim.Property(x => x.Type).HasMaxLength(ApiScopeClaimConsts.TypeMaxLength).IsRequired(); }); } } From bb42f7280f173e9bc59b160ccc4c690c8d75311f Mon Sep 17 00:00:00 2001 From: Alper Ebicoglu Date: Mon, 8 Jan 2018 18:01:49 +0300 Subject: [PATCH 3/3] Added Identity Server initial migrations --- .../IdentityServer/ApiResources/ApiSecret.cs | 2 +- ...8150119_IdentityServer_Initial.Designer.cs | 609 ++++++++++++++++++ .../20180108150119_IdentityServer_Initial.cs | 543 ++++++++++++++++ .../IdentityServerDbContextModelSnapshot.cs | 608 +++++++++++++++++ .../IdentityServerDbContext.cs | 16 +- 5 files changed, 1768 insertions(+), 10 deletions(-) create mode 100644 src/Volo.Abp.IdentityServer.EntityFrameworkCore/Migrations/20180108150119_IdentityServer_Initial.Designer.cs create mode 100644 src/Volo.Abp.IdentityServer.EntityFrameworkCore/Migrations/20180108150119_IdentityServer_Initial.cs create mode 100644 src/Volo.Abp.IdentityServer.EntityFrameworkCore/Migrations/IdentityServerDbContextModelSnapshot.cs diff --git a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiSecret.cs b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiSecret.cs index c18fe95372..2e656dcc3d 100644 --- a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiSecret.cs +++ b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiSecret.cs @@ -4,7 +4,7 @@ namespace Volo.Abp.IdentityServer.ApiResources { public class ApiSecret : Secret { - public virtual string ApiResourceId { get; set; } + public virtual Guid ApiResourceId { get; set; } protected ApiSecret() { diff --git a/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Migrations/20180108150119_IdentityServer_Initial.Designer.cs b/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Migrations/20180108150119_IdentityServer_Initial.Designer.cs new file mode 100644 index 0000000000..580a47ec10 --- /dev/null +++ b/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Migrations/20180108150119_IdentityServer_Initial.Designer.cs @@ -0,0 +1,609 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage; +using Microsoft.EntityFrameworkCore.Storage.Internal; +using System; +using Volo.Abp.IdentityServer.EntityFrameworkCore; + +namespace Volo.Abp.IdentityServer.EntityFrameworkCore.Migrations +{ + [DbContext(typeof(IdentityServerDbContext))] + [Migration("20180108150119_IdentityServer_Initial")] + partial class IdentityServer_Initial + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.0.0-rtm-26452") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResource", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Description") + .HasMaxLength(1000); + + b.Property("DisplayName") + .HasMaxLength(200); + + b.Property("Enabled"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpIdsApiResources"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ApiResourceId"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(200); + + b.HasKey("Id"); + + b.HasIndex("ApiResourceId"); + + b.ToTable("AbpIdsApiClaims"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScope", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ApiResourceId"); + + b.Property("Description") + .HasMaxLength(1000); + + b.Property("DisplayName") + .HasMaxLength(200); + + b.Property("Emphasize"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200); + + b.Property("Required"); + + b.Property("ShowInDiscoveryDocument"); + + b.HasKey("Id"); + + b.HasIndex("ApiResourceId"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpIdsApiScopes"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScopeClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ApiScopeId"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(200); + + b.HasKey("Id"); + + b.HasIndex("ApiScopeId"); + + b.ToTable("AbpIdsApiScopeClaims"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiSecret", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ApiResourceId"); + + b.Property("Description") + .HasMaxLength(1000); + + b.Property("Expiration"); + + b.Property("Type") + .HasMaxLength(250); + + b.Property("Value") + .HasMaxLength(2000); + + b.HasKey("Id"); + + b.HasIndex("ApiResourceId"); + + b.ToTable("AbpIdsApiSecrets"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AbsoluteRefreshTokenLifetime"); + + b.Property("AccessTokenLifetime"); + + b.Property("AccessTokenType"); + + b.Property("AllowAccessTokensViaBrowser"); + + b.Property("AllowOfflineAccess"); + + b.Property("AllowPlainTextPkce"); + + b.Property("AllowRememberConsent"); + + b.Property("AlwaysIncludeUserClaimsInIdToken"); + + b.Property("AlwaysSendClientClaims"); + + b.Property("AuthorizationCodeLifetime"); + + b.Property("BackChannelLogoutSessionRequired"); + + b.Property("BackChannelLogoutUri") + .HasMaxLength(2000); + + b.Property("ClientClaimsPrefix") + .HasMaxLength(200); + + b.Property("ClientId") + .IsRequired() + .HasMaxLength(200); + + b.Property("ClientName") + .HasMaxLength(200); + + b.Property("ClientUri") + .HasMaxLength(2000); + + b.Property("ConsentLifetime"); + + b.Property("Description") + .HasMaxLength(1000); + + b.Property("EnableLocalLogin"); + + b.Property("Enabled"); + + b.Property("FrontChannelLogoutSessionRequired"); + + b.Property("FrontChannelLogoutUri") + .HasMaxLength(2000); + + b.Property("IdentityTokenLifetime"); + + b.Property("IncludeJwtId"); + + b.Property("LogoUri") + .HasMaxLength(2000); + + b.Property("PairWiseSubjectSalt") + .HasMaxLength(200); + + b.Property("ProtocolType") + .IsRequired() + .HasMaxLength(200); + + b.Property("RefreshTokenExpiration"); + + b.Property("RefreshTokenUsage"); + + b.Property("RequireClientSecret"); + + b.Property("RequireConsent"); + + b.Property("RequirePkce"); + + b.Property("SlidingRefreshTokenLifetime"); + + b.Property("UpdateAccessTokenClaimsOnRefresh"); + + b.HasKey("Id"); + + b.HasIndex("ClientId") + .IsUnique(); + + b.ToTable("AbpIdsClients"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClientId"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(250); + + b.Property("Value") + .IsRequired() + .HasMaxLength(250); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.ToTable("AbpIdsClientClaims"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientCorsOrigin", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClientId"); + + b.Property("Origin") + .IsRequired() + .HasMaxLength(150); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.ToTable("AbpIdsClientCorsOrigins"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientGrantType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClientId"); + + b.Property("GrantType") + .IsRequired() + .HasMaxLength(250); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.ToTable("AbpIdsClientGrantTypes"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientIdPRestriction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClientId"); + + b.Property("Provider") + .IsRequired() + .HasMaxLength(200); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.ToTable("AbpIdsClientIdPRestrictions"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientPostLogoutRedirectUri", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClientId"); + + b.Property("PostLogoutRedirectUri") + .IsRequired() + .HasMaxLength(2000); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.ToTable("AbpIdsClientPostLogoutRedirectUris"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientProperty", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClientId"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(250); + + b.Property("Value") + .IsRequired() + .HasMaxLength(2000); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.ToTable("AbpIdsClientProperties"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientRedirectUri", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClientId"); + + b.Property("RedirectUri") + .IsRequired() + .HasMaxLength(2000); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.ToTable("AbpIdsClientRedirectUris"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientScope", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClientId"); + + b.Property("Scope") + .IsRequired() + .HasMaxLength(200); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.ToTable("AbpIdsClientScopes"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientSecret", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClientId"); + + b.Property("Description") + .HasMaxLength(2000); + + b.Property("Expiration"); + + b.Property("Type") + .HasMaxLength(250); + + b.Property("Value") + .IsRequired() + .HasMaxLength(2000); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.ToTable("AbpIdsClientSecrets"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Grants.PersistedGrant", b => + { + b.Property("Key") + .HasMaxLength(200); + + b.Property("ClientId") + .IsRequired() + .HasMaxLength(200); + + b.Property("CreationTime"); + + b.Property("Data") + .IsRequired(); + + b.Property("Expiration"); + + b.Property("Id"); + + b.Property("SubjectId") + .HasMaxLength(200); + + b.Property("Type") + .IsRequired() + .HasMaxLength(50); + + b.HasKey("Key"); + + b.HasIndex("SubjectId", "ClientId", "Type"); + + b.ToTable("AbpIdsPersistedGrants"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("IdentityResourceId"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(200); + + b.HasKey("Id"); + + b.HasIndex("IdentityResourceId"); + + b.ToTable("AbpIdsIdentityClaims"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityResource", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Description") + .HasMaxLength(1000); + + b.Property("DisplayName") + .HasMaxLength(200); + + b.Property("Emphasize"); + + b.Property("Enabled"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200); + + b.Property("Required"); + + b.Property("ShowInDiscoveryDocument"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpIdsIdentityResources"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceClaim", b => + { + b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource") + .WithMany("UserClaims") + .HasForeignKey("ApiResourceId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScope", b => + { + b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource") + .WithMany("Scopes") + .HasForeignKey("ApiResourceId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScopeClaim", b => + { + b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiScope") + .WithMany("UserClaims") + .HasForeignKey("ApiScopeId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiSecret", b => + { + b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource") + .WithMany("Secrets") + .HasForeignKey("ApiResourceId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientClaim", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("Claims") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientCorsOrigin", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("AllowedCorsOrigins") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientGrantType", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("AllowedGrantTypes") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientIdPRestriction", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("IdentityProviderRestrictions") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientPostLogoutRedirectUri", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("PostLogoutRedirectUris") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientProperty", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("Properties") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientRedirectUri", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("RedirectUris") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientScope", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("AllowedScopes") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientSecret", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("ClientSecrets") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityClaim", b => + { + b.HasOne("Volo.Abp.IdentityServer.IdentityResources.IdentityResource") + .WithMany("UserClaims") + .HasForeignKey("IdentityResourceId") + .OnDelete(DeleteBehavior.Cascade); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Migrations/20180108150119_IdentityServer_Initial.cs b/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Migrations/20180108150119_IdentityServer_Initial.cs new file mode 100644 index 0000000000..e335b5dc75 --- /dev/null +++ b/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Migrations/20180108150119_IdentityServer_Initial.cs @@ -0,0 +1,543 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using System; +using System.Collections.Generic; + +namespace Volo.Abp.IdentityServer.EntityFrameworkCore.Migrations +{ + public partial class IdentityServer_Initial : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "AbpIdsApiResources", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + DisplayName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + Enabled = table.Column(type: "bit", nullable: false), + Name = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpIdsApiResources", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpIdsClients", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + AbsoluteRefreshTokenLifetime = table.Column(type: "int", nullable: false), + AccessTokenLifetime = table.Column(type: "int", nullable: false), + AccessTokenType = table.Column(type: "int", nullable: false), + AllowAccessTokensViaBrowser = table.Column(type: "bit", nullable: false), + AllowOfflineAccess = table.Column(type: "bit", nullable: false), + AllowPlainTextPkce = table.Column(type: "bit", nullable: false), + AllowRememberConsent = table.Column(type: "bit", nullable: false), + AlwaysIncludeUserClaimsInIdToken = table.Column(type: "bit", nullable: false), + AlwaysSendClientClaims = table.Column(type: "bit", nullable: false), + AuthorizationCodeLifetime = table.Column(type: "int", nullable: false), + BackChannelLogoutSessionRequired = table.Column(type: "bit", nullable: false), + BackChannelLogoutUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + ClientClaimsPrefix = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + ClientId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + ClientName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + ClientUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + ConsentLifetime = table.Column(type: "int", nullable: true), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + EnableLocalLogin = table.Column(type: "bit", nullable: false), + Enabled = table.Column(type: "bit", nullable: false), + FrontChannelLogoutSessionRequired = table.Column(type: "bit", nullable: false), + FrontChannelLogoutUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + IdentityTokenLifetime = table.Column(type: "int", nullable: false), + IncludeJwtId = table.Column(type: "bit", nullable: false), + LogoUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + PairWiseSubjectSalt = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + ProtocolType = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + RefreshTokenExpiration = table.Column(type: "int", nullable: false), + RefreshTokenUsage = table.Column(type: "int", nullable: false), + RequireClientSecret = table.Column(type: "bit", nullable: false), + RequireConsent = table.Column(type: "bit", nullable: false), + RequirePkce = table.Column(type: "bit", nullable: false), + SlidingRefreshTokenLifetime = table.Column(type: "int", nullable: false), + UpdateAccessTokenClaimsOnRefresh = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpIdsClients", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpIdsIdentityResources", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + DisplayName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + Emphasize = table.Column(type: "bit", nullable: false), + Enabled = table.Column(type: "bit", nullable: false), + Name = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + Required = table.Column(type: "bit", nullable: false), + ShowInDiscoveryDocument = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpIdsIdentityResources", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpIdsPersistedGrants", + columns: table => new + { + Key = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + ClientId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + CreationTime = table.Column(type: "datetime2", nullable: false), + Data = table.Column(type: "nvarchar(max)", nullable: false), + Expiration = table.Column(type: "datetime2", nullable: true), + Id = table.Column(type: "uniqueidentifier", nullable: false), + SubjectId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + Type = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpIdsPersistedGrants", x => x.Key); + }); + + migrationBuilder.CreateTable( + name: "AbpIdsApiClaims", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ApiResourceId = table.Column(type: "uniqueidentifier", nullable: false), + Type = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpIdsApiClaims", x => x.Id); + table.ForeignKey( + name: "FK_AbpIdsApiClaims_AbpIdsApiResources_ApiResourceId", + column: x => x.ApiResourceId, + principalTable: "AbpIdsApiResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpIdsApiScopes", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ApiResourceId = table.Column(type: "uniqueidentifier", nullable: false), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + DisplayName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + Emphasize = table.Column(type: "bit", nullable: false), + Name = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + Required = table.Column(type: "bit", nullable: false), + ShowInDiscoveryDocument = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpIdsApiScopes", x => x.Id); + table.ForeignKey( + name: "FK_AbpIdsApiScopes_AbpIdsApiResources_ApiResourceId", + column: x => x.ApiResourceId, + principalTable: "AbpIdsApiResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpIdsApiSecrets", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ApiResourceId = table.Column(type: "uniqueidentifier", nullable: false), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + Expiration = table.Column(type: "datetime2", nullable: true), + Type = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: true), + Value = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpIdsApiSecrets", x => x.Id); + table.ForeignKey( + name: "FK_AbpIdsApiSecrets_AbpIdsApiResources_ApiResourceId", + column: x => x.ApiResourceId, + principalTable: "AbpIdsApiResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpIdsClientClaims", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + Type = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), + Value = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpIdsClientClaims", x => x.Id); + table.ForeignKey( + name: "FK_AbpIdsClientClaims_AbpIdsClients_ClientId", + column: x => x.ClientId, + principalTable: "AbpIdsClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpIdsClientCorsOrigins", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + Origin = table.Column(type: "nvarchar(150)", maxLength: 150, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpIdsClientCorsOrigins", x => x.Id); + table.ForeignKey( + name: "FK_AbpIdsClientCorsOrigins_AbpIdsClients_ClientId", + column: x => x.ClientId, + principalTable: "AbpIdsClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpIdsClientGrantTypes", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + GrantType = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpIdsClientGrantTypes", x => x.Id); + table.ForeignKey( + name: "FK_AbpIdsClientGrantTypes_AbpIdsClients_ClientId", + column: x => x.ClientId, + principalTable: "AbpIdsClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpIdsClientIdPRestrictions", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + Provider = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpIdsClientIdPRestrictions", x => x.Id); + table.ForeignKey( + name: "FK_AbpIdsClientIdPRestrictions_AbpIdsClients_ClientId", + column: x => x.ClientId, + principalTable: "AbpIdsClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpIdsClientPostLogoutRedirectUris", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + PostLogoutRedirectUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpIdsClientPostLogoutRedirectUris", x => x.Id); + table.ForeignKey( + name: "FK_AbpIdsClientPostLogoutRedirectUris_AbpIdsClients_ClientId", + column: x => x.ClientId, + principalTable: "AbpIdsClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpIdsClientProperties", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + Key = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), + Value = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpIdsClientProperties", x => x.Id); + table.ForeignKey( + name: "FK_AbpIdsClientProperties_AbpIdsClients_ClientId", + column: x => x.ClientId, + principalTable: "AbpIdsClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpIdsClientRedirectUris", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + RedirectUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpIdsClientRedirectUris", x => x.Id); + table.ForeignKey( + name: "FK_AbpIdsClientRedirectUris_AbpIdsClients_ClientId", + column: x => x.ClientId, + principalTable: "AbpIdsClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpIdsClientScopes", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + Scope = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpIdsClientScopes", x => x.Id); + table.ForeignKey( + name: "FK_AbpIdsClientScopes_AbpIdsClients_ClientId", + column: x => x.ClientId, + principalTable: "AbpIdsClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpIdsClientSecrets", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + Description = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + Expiration = table.Column(type: "datetime2", nullable: true), + Type = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: true), + Value = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpIdsClientSecrets", x => x.Id); + table.ForeignKey( + name: "FK_AbpIdsClientSecrets_AbpIdsClients_ClientId", + column: x => x.ClientId, + principalTable: "AbpIdsClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpIdsIdentityClaims", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + IdentityResourceId = table.Column(type: "uniqueidentifier", nullable: false), + Type = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpIdsIdentityClaims", x => x.Id); + table.ForeignKey( + name: "FK_AbpIdsIdentityClaims_AbpIdsIdentityResources_IdentityResourceId", + column: x => x.IdentityResourceId, + principalTable: "AbpIdsIdentityResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpIdsApiScopeClaims", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ApiScopeId = table.Column(type: "uniqueidentifier", nullable: false), + Type = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpIdsApiScopeClaims", x => x.Id); + table.ForeignKey( + name: "FK_AbpIdsApiScopeClaims_AbpIdsApiScopes_ApiScopeId", + column: x => x.ApiScopeId, + principalTable: "AbpIdsApiScopes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_AbpIdsApiClaims_ApiResourceId", + table: "AbpIdsApiClaims", + column: "ApiResourceId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpIdsApiResources_Name", + table: "AbpIdsApiResources", + column: "Name", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_AbpIdsApiScopeClaims_ApiScopeId", + table: "AbpIdsApiScopeClaims", + column: "ApiScopeId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpIdsApiScopes_ApiResourceId", + table: "AbpIdsApiScopes", + column: "ApiResourceId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpIdsApiScopes_Name", + table: "AbpIdsApiScopes", + column: "Name", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_AbpIdsApiSecrets_ApiResourceId", + table: "AbpIdsApiSecrets", + column: "ApiResourceId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpIdsClientClaims_ClientId", + table: "AbpIdsClientClaims", + column: "ClientId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpIdsClientCorsOrigins_ClientId", + table: "AbpIdsClientCorsOrigins", + column: "ClientId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpIdsClientGrantTypes_ClientId", + table: "AbpIdsClientGrantTypes", + column: "ClientId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpIdsClientIdPRestrictions_ClientId", + table: "AbpIdsClientIdPRestrictions", + column: "ClientId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpIdsClientPostLogoutRedirectUris_ClientId", + table: "AbpIdsClientPostLogoutRedirectUris", + column: "ClientId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpIdsClientProperties_ClientId", + table: "AbpIdsClientProperties", + column: "ClientId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpIdsClientRedirectUris_ClientId", + table: "AbpIdsClientRedirectUris", + column: "ClientId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpIdsClients_ClientId", + table: "AbpIdsClients", + column: "ClientId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_AbpIdsClientScopes_ClientId", + table: "AbpIdsClientScopes", + column: "ClientId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpIdsClientSecrets_ClientId", + table: "AbpIdsClientSecrets", + column: "ClientId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpIdsIdentityClaims_IdentityResourceId", + table: "AbpIdsIdentityClaims", + column: "IdentityResourceId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpIdsIdentityResources_Name", + table: "AbpIdsIdentityResources", + column: "Name", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_AbpIdsPersistedGrants_SubjectId_ClientId_Type", + table: "AbpIdsPersistedGrants", + columns: new[] { "SubjectId", "ClientId", "Type" }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AbpIdsApiClaims"); + + migrationBuilder.DropTable( + name: "AbpIdsApiScopeClaims"); + + migrationBuilder.DropTable( + name: "AbpIdsApiSecrets"); + + migrationBuilder.DropTable( + name: "AbpIdsClientClaims"); + + migrationBuilder.DropTable( + name: "AbpIdsClientCorsOrigins"); + + migrationBuilder.DropTable( + name: "AbpIdsClientGrantTypes"); + + migrationBuilder.DropTable( + name: "AbpIdsClientIdPRestrictions"); + + migrationBuilder.DropTable( + name: "AbpIdsClientPostLogoutRedirectUris"); + + migrationBuilder.DropTable( + name: "AbpIdsClientProperties"); + + migrationBuilder.DropTable( + name: "AbpIdsClientRedirectUris"); + + migrationBuilder.DropTable( + name: "AbpIdsClientScopes"); + + migrationBuilder.DropTable( + name: "AbpIdsClientSecrets"); + + migrationBuilder.DropTable( + name: "AbpIdsIdentityClaims"); + + migrationBuilder.DropTable( + name: "AbpIdsPersistedGrants"); + + migrationBuilder.DropTable( + name: "AbpIdsApiScopes"); + + migrationBuilder.DropTable( + name: "AbpIdsClients"); + + migrationBuilder.DropTable( + name: "AbpIdsIdentityResources"); + + migrationBuilder.DropTable( + name: "AbpIdsApiResources"); + } + } +} diff --git a/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Migrations/IdentityServerDbContextModelSnapshot.cs b/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Migrations/IdentityServerDbContextModelSnapshot.cs new file mode 100644 index 0000000000..8fc627b5ff --- /dev/null +++ b/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Migrations/IdentityServerDbContextModelSnapshot.cs @@ -0,0 +1,608 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage; +using Microsoft.EntityFrameworkCore.Storage.Internal; +using System; +using Volo.Abp.IdentityServer.EntityFrameworkCore; + +namespace Volo.Abp.IdentityServer.EntityFrameworkCore.Migrations +{ + [DbContext(typeof(IdentityServerDbContext))] + partial class IdentityServerDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.0.0-rtm-26452") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResource", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Description") + .HasMaxLength(1000); + + b.Property("DisplayName") + .HasMaxLength(200); + + b.Property("Enabled"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpIdsApiResources"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ApiResourceId"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(200); + + b.HasKey("Id"); + + b.HasIndex("ApiResourceId"); + + b.ToTable("AbpIdsApiClaims"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScope", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ApiResourceId"); + + b.Property("Description") + .HasMaxLength(1000); + + b.Property("DisplayName") + .HasMaxLength(200); + + b.Property("Emphasize"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200); + + b.Property("Required"); + + b.Property("ShowInDiscoveryDocument"); + + b.HasKey("Id"); + + b.HasIndex("ApiResourceId"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpIdsApiScopes"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScopeClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ApiScopeId"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(200); + + b.HasKey("Id"); + + b.HasIndex("ApiScopeId"); + + b.ToTable("AbpIdsApiScopeClaims"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiSecret", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ApiResourceId"); + + b.Property("Description") + .HasMaxLength(1000); + + b.Property("Expiration"); + + b.Property("Type") + .HasMaxLength(250); + + b.Property("Value") + .HasMaxLength(2000); + + b.HasKey("Id"); + + b.HasIndex("ApiResourceId"); + + b.ToTable("AbpIdsApiSecrets"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AbsoluteRefreshTokenLifetime"); + + b.Property("AccessTokenLifetime"); + + b.Property("AccessTokenType"); + + b.Property("AllowAccessTokensViaBrowser"); + + b.Property("AllowOfflineAccess"); + + b.Property("AllowPlainTextPkce"); + + b.Property("AllowRememberConsent"); + + b.Property("AlwaysIncludeUserClaimsInIdToken"); + + b.Property("AlwaysSendClientClaims"); + + b.Property("AuthorizationCodeLifetime"); + + b.Property("BackChannelLogoutSessionRequired"); + + b.Property("BackChannelLogoutUri") + .HasMaxLength(2000); + + b.Property("ClientClaimsPrefix") + .HasMaxLength(200); + + b.Property("ClientId") + .IsRequired() + .HasMaxLength(200); + + b.Property("ClientName") + .HasMaxLength(200); + + b.Property("ClientUri") + .HasMaxLength(2000); + + b.Property("ConsentLifetime"); + + b.Property("Description") + .HasMaxLength(1000); + + b.Property("EnableLocalLogin"); + + b.Property("Enabled"); + + b.Property("FrontChannelLogoutSessionRequired"); + + b.Property("FrontChannelLogoutUri") + .HasMaxLength(2000); + + b.Property("IdentityTokenLifetime"); + + b.Property("IncludeJwtId"); + + b.Property("LogoUri") + .HasMaxLength(2000); + + b.Property("PairWiseSubjectSalt") + .HasMaxLength(200); + + b.Property("ProtocolType") + .IsRequired() + .HasMaxLength(200); + + b.Property("RefreshTokenExpiration"); + + b.Property("RefreshTokenUsage"); + + b.Property("RequireClientSecret"); + + b.Property("RequireConsent"); + + b.Property("RequirePkce"); + + b.Property("SlidingRefreshTokenLifetime"); + + b.Property("UpdateAccessTokenClaimsOnRefresh"); + + b.HasKey("Id"); + + b.HasIndex("ClientId") + .IsUnique(); + + b.ToTable("AbpIdsClients"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClientId"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(250); + + b.Property("Value") + .IsRequired() + .HasMaxLength(250); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.ToTable("AbpIdsClientClaims"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientCorsOrigin", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClientId"); + + b.Property("Origin") + .IsRequired() + .HasMaxLength(150); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.ToTable("AbpIdsClientCorsOrigins"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientGrantType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClientId"); + + b.Property("GrantType") + .IsRequired() + .HasMaxLength(250); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.ToTable("AbpIdsClientGrantTypes"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientIdPRestriction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClientId"); + + b.Property("Provider") + .IsRequired() + .HasMaxLength(200); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.ToTable("AbpIdsClientIdPRestrictions"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientPostLogoutRedirectUri", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClientId"); + + b.Property("PostLogoutRedirectUri") + .IsRequired() + .HasMaxLength(2000); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.ToTable("AbpIdsClientPostLogoutRedirectUris"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientProperty", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClientId"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(250); + + b.Property("Value") + .IsRequired() + .HasMaxLength(2000); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.ToTable("AbpIdsClientProperties"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientRedirectUri", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClientId"); + + b.Property("RedirectUri") + .IsRequired() + .HasMaxLength(2000); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.ToTable("AbpIdsClientRedirectUris"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientScope", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClientId"); + + b.Property("Scope") + .IsRequired() + .HasMaxLength(200); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.ToTable("AbpIdsClientScopes"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientSecret", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClientId"); + + b.Property("Description") + .HasMaxLength(2000); + + b.Property("Expiration"); + + b.Property("Type") + .HasMaxLength(250); + + b.Property("Value") + .IsRequired() + .HasMaxLength(2000); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.ToTable("AbpIdsClientSecrets"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Grants.PersistedGrant", b => + { + b.Property("Key") + .HasMaxLength(200); + + b.Property("ClientId") + .IsRequired() + .HasMaxLength(200); + + b.Property("CreationTime"); + + b.Property("Data") + .IsRequired(); + + b.Property("Expiration"); + + b.Property("Id"); + + b.Property("SubjectId") + .HasMaxLength(200); + + b.Property("Type") + .IsRequired() + .HasMaxLength(50); + + b.HasKey("Key"); + + b.HasIndex("SubjectId", "ClientId", "Type"); + + b.ToTable("AbpIdsPersistedGrants"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("IdentityResourceId"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(200); + + b.HasKey("Id"); + + b.HasIndex("IdentityResourceId"); + + b.ToTable("AbpIdsIdentityClaims"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityResource", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Description") + .HasMaxLength(1000); + + b.Property("DisplayName") + .HasMaxLength(200); + + b.Property("Emphasize"); + + b.Property("Enabled"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200); + + b.Property("Required"); + + b.Property("ShowInDiscoveryDocument"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpIdsIdentityResources"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceClaim", b => + { + b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource") + .WithMany("UserClaims") + .HasForeignKey("ApiResourceId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScope", b => + { + b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource") + .WithMany("Scopes") + .HasForeignKey("ApiResourceId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScopeClaim", b => + { + b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiScope") + .WithMany("UserClaims") + .HasForeignKey("ApiScopeId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiSecret", b => + { + b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource") + .WithMany("Secrets") + .HasForeignKey("ApiResourceId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientClaim", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("Claims") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientCorsOrigin", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("AllowedCorsOrigins") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientGrantType", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("AllowedGrantTypes") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientIdPRestriction", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("IdentityProviderRestrictions") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientPostLogoutRedirectUri", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("PostLogoutRedirectUris") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientProperty", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("Properties") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientRedirectUri", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("RedirectUris") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientScope", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("AllowedScopes") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientSecret", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("ClientSecrets") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityClaim", b => + { + b.HasOne("Volo.Abp.IdentityServer.IdentityResources.IdentityResource") + .WithMany("UserClaims") + .HasForeignKey("IdentityResourceId") + .OnDelete(DeleteBehavior.Cascade); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContext.cs b/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContext.cs index d56db360f0..ae82b5bb06 100644 --- a/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContext.cs +++ b/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContext.cs @@ -61,8 +61,6 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore { client.ToTable(TablePrefix + "Clients"); - client.HasKey(x => x.Id); - client.Property(x => x.ClientId).HasMaxLength(ClientConsts.ClientIdMaxLength).IsRequired(); client.Property(x => x.ProtocolType).HasMaxLength(ClientConsts.ProtocolTypeMaxLength).IsRequired(); client.Property(x => x.ClientName).HasMaxLength(ClientConsts.ClientNameMaxLength); @@ -165,7 +163,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore builder.Entity(identityResource => { - identityResource.ToTable(TablePrefix + "IdentityResources").HasKey(x => x.Id); + identityResource.ToTable(TablePrefix + "IdentityResources"); identityResource.Property(x => x.Name).HasMaxLength(IdentityResourceConsts.NameMaxLength).IsRequired(); identityResource.Property(x => x.DisplayName).HasMaxLength(IdentityResourceConsts.DisplayNameMaxLength); @@ -179,14 +177,14 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore builder.Entity(claim => { - claim.ToTable(TablePrefix + "IdentityClaims").HasKey(x => x.Id); + claim.ToTable(TablePrefix + "IdentityClaims"); claim.Property(x => x.Type).HasMaxLength(IdentityClaimConsts.TypeMaxLength).IsRequired(); }); builder.Entity(apiResource => { - apiResource.ToTable(TablePrefix + "ApiResources").HasKey(x => x.Id); + apiResource.ToTable(TablePrefix + "ApiResources"); apiResource.Property(x => x.Name).HasMaxLength(ApiResourceConsts.NameMaxLength).IsRequired(); apiResource.Property(x => x.DisplayName).HasMaxLength(ApiResourceConsts.DisplayNameMaxLength); @@ -201,7 +199,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore builder.Entity(apiSecret => { - apiSecret.ToTable(TablePrefix + "ApiSecrets").HasKey(x => x.Id); + apiSecret.ToTable(TablePrefix + "ApiSecrets"); apiSecret.Property(x => x.Description).HasMaxLength(ApiSecretConsts.DescriptionMaxLength); apiSecret.Property(x => x.Value).HasMaxLength(ApiSecretConsts.ValueMaxLength); @@ -210,14 +208,14 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore builder.Entity(apiClaim => { - apiClaim.ToTable(TablePrefix + "ApiClaims").HasKey(x => x.Id); + apiClaim.ToTable(TablePrefix + "ApiClaims"); apiClaim.Property(x => x.Type).HasMaxLength(ApiResourceClaimConsts.TypeMaxLength).IsRequired(); }); builder.Entity(apiScope => { - apiScope.ToTable(TablePrefix + "ApiScopes").HasKey(x => x.Id); + apiScope.ToTable(TablePrefix + "ApiScopes"); apiScope.Property(x => x.Name).HasMaxLength(ApiScopeConsts.NameMaxLength).IsRequired(); apiScope.Property(x => x.DisplayName).HasMaxLength(ApiScopeConsts.DisplayNameMaxLength); @@ -230,7 +228,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore builder.Entity(apiScopeClaim => { - apiScopeClaim.ToTable(TablePrefix + "ApiScopeClaims").HasKey(x => x.Id); + apiScopeClaim.ToTable(TablePrefix + "ApiScopeClaims"); apiScopeClaim.Property(x => x.Type).HasMaxLength(ApiScopeClaimConsts.TypeMaxLength).IsRequired(); });