Configure IdentityServer database mapping based on the database provider.

pull/1936/head
Halil İbrahim Kalkan 5 years ago
parent 93e5811d0c
commit 647b863d6f

@ -0,0 +1,14 @@
namespace Volo.Abp.EntityFrameworkCore
{
public enum EfCoreDatabaseProvider
{
SqlServer,
MySql,
Oracle,
PostgreSql,
Sqlite,
InMemory,
Cosmos,
Firebird
}
}

@ -2,6 +2,7 @@
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.Modeling;
using Volo.Abp.IdentityServer.ApiResources;
using Volo.Abp.IdentityServer.Clients;
@ -71,7 +72,14 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
redirectUri.HasKey(x => new { x.ClientId, x.RedirectUri });
redirectUri.Property(x => x.RedirectUri).HasMaxLength(ClientRedirectUriConsts.RedirectUriMaxLength).IsRequired();
if (options.DatabaseProvider == EfCoreDatabaseProvider.MySql)
{
redirectUri.Property(x => x.RedirectUri).HasMaxLength(300).IsRequired();
}
else
{
redirectUri.Property(x => x.RedirectUri).HasMaxLength(ClientRedirectUriConsts.RedirectUriMaxLength).IsRequired();
}
});
builder.Entity<ClientPostLogoutRedirectUri>(postLogoutRedirectUri =>
@ -80,7 +88,14 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
postLogoutRedirectUri.HasKey(x => new { x.ClientId, x.PostLogoutRedirectUri });
postLogoutRedirectUri.Property(x => x.PostLogoutRedirectUri).HasMaxLength(ClientPostLogoutRedirectUriConsts.PostLogoutRedirectUriMaxLength).IsRequired();
if (options.DatabaseProvider == EfCoreDatabaseProvider.MySql)
{
postLogoutRedirectUri.Property(x => x.PostLogoutRedirectUri).HasMaxLength(300).IsRequired();
}
else
{
postLogoutRedirectUri.Property(x => x.PostLogoutRedirectUri).HasMaxLength(ClientPostLogoutRedirectUriConsts.PostLogoutRedirectUriMaxLength).IsRequired();
}
});
builder.Entity<ClientScope>(scope =>
@ -99,7 +114,16 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
secret.HasKey(x => new { x.ClientId, x.Type, x.Value });
secret.Property(x => x.Type).HasMaxLength(SecretConsts.TypeMaxLength).IsRequired();
secret.Property(x => x.Value).HasMaxLength(SecretConsts.ValueMaxLength).IsRequired();
if (options.DatabaseProvider == EfCoreDatabaseProvider.MySql)
{
secret.Property(x => x.Value).HasMaxLength(300).IsRequired();
}
else
{
secret.Property(x => x.Value).HasMaxLength(SecretConsts.ValueMaxLength).IsRequired();
}
secret.Property(x => x.Description).HasMaxLength(SecretConsts.DescriptionMaxLength);
});
@ -214,7 +238,16 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
apiSecret.HasKey(x => new { x.ApiResourceId, x.Type, x.Value });
apiSecret.Property(x => x.Type).HasMaxLength(SecretConsts.TypeMaxLength).IsRequired();
apiSecret.Property(x => x.Value).HasMaxLength(SecretConsts.ValueMaxLength).IsRequired();
if (options.DatabaseProvider == EfCoreDatabaseProvider.MySql)
{
apiSecret.Property(x => x.Value).HasMaxLength(300).IsRequired();
}
else
{
apiSecret.Property(x => x.Value).HasMaxLength(SecretConsts.ValueMaxLength).IsRequired();
}
apiSecret.Property(x => x.Description).HasMaxLength(SecretConsts.DescriptionMaxLength);
});

@ -1,10 +1,13 @@
using JetBrains.Annotations;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.Modeling;
namespace Volo.Abp.IdentityServer.EntityFrameworkCore
{
public class IdentityServerModelBuilderConfigurationOptions : ModelBuilderConfigurationOptions
{
public EfCoreDatabaseProvider? DatabaseProvider { get; set; }
public IdentityServerModelBuilderConfigurationOptions(
[NotNull] string tablePrefix,
[CanBeNull] string schema)

Loading…
Cancel
Save