Browse Source

Identity Server is done.

pull/4578/head
maliming 6 years ago
parent
commit
0a8423d0b0
  1. 12
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiResourceConsts.cs
  2. 4
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiResourceEto.cs
  3. 9
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiResourcePropertyConsts.cs
  4. 4
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiResourceScopeConsts.cs
  5. 6
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiResourceSecretConsts.cs
  6. 8
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiScopes/ApiResourceConsts.cs
  7. 7
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiScopes/ApiScopeClaimConsts.cs
  8. 6
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiScopes/ApiScopePropertyConsts.cs
  9. 7
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Clients/ClientClaimConsts.cs
  10. 24
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Clients/ClientConsts.cs
  11. 4
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Clients/ClientCorsOriginConsts.cs
  12. 4
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Clients/ClientGrantTypeConsts.cs
  13. 19
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Devices/DeviceFlowCodesConsts.cs
  14. 22
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Grants/PersistedGrantConsts.cs
  15. 8
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceConsts.cs
  16. 6
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/IdentityResources/IdentityResourcePropertyConsts.cs
  17. 9
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/ObjectExtending/IdentityServerModuleExtensionConfiguration.cs
  18. 4
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/ObjectExtending/IdentityServerModuleExtensionConsts.cs
  19. 1
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerDomainModule.cs
  20. 25
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResource.cs
  21. 39
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResourceProperty.cs
  22. 5
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/IApiResourceRepository.cs
  23. 4
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiScopes/ApiScope.cs
  24. 14
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiScopes/ApiScopeClaim.cs
  25. 4
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceProperty.cs
  26. 117
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityServerAutoMapperProfile.cs
  27. 3
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/AbpIdentityServerEfCoreQueryableExtensions.cs
  28. 9
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/ApiResources/ApiResourceRepository.cs
  29. 1
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/AbpIdentityServerEntityFrameworkCoreModule.cs
  30. 1
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IIdentityServerDbContext.cs
  31. 1
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContext.cs
  32. 111
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs
  33. 2
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs

12
modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiResourceConsts.cs

@ -1,9 +1,11 @@
namespace Volo.Abp.IdentityServer.ApiScopes namespace Volo.Abp.IdentityServer.ApiResources
{ {
public class ApiResourceConsts public class ApiResourceConsts
{ {
public const int NameMaxLength = 200; public static int NameMaxLength { get; set; } = 200;
public const int DisplayNameMaxLength = 200;
public const int DescriptionMaxLength = 1000; public static int DisplayNameMaxLength { get; set; } = 200;
public static int DescriptionMaxLength { get; set; } = 1000;
} }
} }

4
modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiResourceEto.cs

@ -1,7 +1,7 @@
using System; using System;
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Volo.Abp.IdentityServer.ApiScopes namespace Volo.Abp.IdentityServer.ApiResources
{ {
[Serializable] [Serializable]
public class ApiResourceEto public class ApiResourceEto
@ -17,4 +17,4 @@ namespace Volo.Abp.IdentityServer.ApiScopes
public bool Enabled { get; set; } public bool Enabled { get; set; }
} }
} }

9
modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiResourcePropertyConsts.cs

@ -0,0 +1,9 @@
namespace Volo.Abp.IdentityServer.ApiResources
{
public class ApiResourcePropertyConsts
{
public static int KeyMaxLength { get; set; } = 250;
public static int ValueMaxLength { get; set; } = 2000;
}
}

4
modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiResourceScopeConsts.cs

@ -1,7 +1,7 @@
namespace Volo.Abp.IdentityServer.ApiScopes namespace Volo.Abp.IdentityServer.ApiResources
{ {
public class ApiResourceScopeConsts public class ApiResourceScopeConsts
{ {
public const int ScopeMaxLength = 200; public static int ScopeMaxLength { get; set; } = 200;
} }
} }

6
modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiResourceSecretConsts.cs

@ -1,4 +1,4 @@
namespace Volo.Abp.IdentityServer.ApiScopes namespace Volo.Abp.IdentityServer.ApiResources
{ {
public class ApiResourceSecretConsts public class ApiResourceSecretConsts
{ {
@ -15,8 +15,8 @@
public static int ValueMaxLengthValue { get; set; } = ValueMaxLength; public static int ValueMaxLengthValue { get; set; } = ValueMaxLength;
/// <summary> /// <summary>
/// Default value: 2000 /// Default value: 1000
/// </summary> /// </summary>
public static int DescriptionMaxLength { get; set; } = 2000; public static int DescriptionMaxLength { get; set; } = 1000;
} }
} }

8
modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiScopes/ApiResourceConsts.cs

@ -2,8 +2,10 @@
{ {
public class ApiScopeConsts public class ApiScopeConsts
{ {
public const int NameMaxLength = 200; public static int NameMaxLength { get; set; } = 200;
public const int DisplayNameMaxLength = 200;
public const int DescriptionMaxLength = 1000; public static int DisplayNameMaxLength { get; set; } = 200;
public static int DescriptionMaxLength { get; set; } = 1000;
} }
} }

7
modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiScopes/ApiScopeClaimConsts.cs

@ -1,7 +0,0 @@
namespace Volo.Abp.IdentityServer.ApiScopes
{
public class ApiScopeClaimConsts
{
public const int NameMaxLength = 200;
}
}

6
modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiScopes/ApiScopePropertyConsts.cs

@ -2,8 +2,8 @@
{ {
public class ApiScopePropertyConsts public class ApiScopePropertyConsts
{ {
public const int KeyMaxLength = 250; public static int KeyMaxLength { get; set; } = 250;
public const int ValueMaxLength = 2000;
public static int ValueMaxLengthValue { get; set; } = ValueMaxLength; public static int ValueMaxLength { get; set; } = 2000;
} }
} }

7
modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Clients/ClientClaimConsts.cs

@ -2,7 +2,8 @@
{ {
public class ClientClaimConsts public class ClientClaimConsts
{ {
public const int TypeMaxLength = 250; public static int TypeMaxLength { get; set; } = 250;
public const int ValueMaxLength = 250;
public static int ValueMaxLength { get; set; } = 250;
} }
} }

24
modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Clients/ClientConsts.cs

@ -2,26 +2,26 @@
{ {
public class ClientConsts public class ClientConsts
{ {
public const int ClientIdMaxLength = 200; public static int ClientIdMaxLength { get; set; } = 200;
public const int ProtocolTypeMaxLength = 200; public static int ProtocolTypeMaxLength { get; set; } = 200;
public const int ClientNameMaxLength = 200; public static int ClientNameMaxLength { get; set; } = 200;
public const int ClientUriMaxLength = 2000; public static int ClientUriMaxLength { get; set; } = 2000;
public const int LogoUriMaxLength = 2000; public static int LogoUriMaxLength { get; set; } = 2000;
public const int DescriptionMaxLength = 1000; public static int DescriptionMaxLength { get; set; } = 1000;
public const int FrontChannelLogoutUriMaxLength = 2000; public static int FrontChannelLogoutUriMaxLength { get; set; } = 2000;
public const int BackChannelLogoutUriMaxLength = 2000; public static int BackChannelLogoutUriMaxLength { get; set; } = 2000;
public const int ClientClaimsPrefixMaxLength = 200; public static int ClientClaimsPrefixMaxLength { get; set; } = 200;
public const int PairWiseSubjectSaltMaxLength = 200; public static int PairWiseSubjectSaltMaxLength { get; set; } = 200;
public const int UserCodeTypeMaxLength = 100; public static int UserCodeTypeMaxLength { get; set; } = 100;
} }
} }

4
modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Clients/ClientCorsOriginConsts.cs

@ -2,6 +2,6 @@
{ {
public class ClientCorsOriginConsts public class ClientCorsOriginConsts
{ {
public const int OriginMaxLength = 150; public static int OriginMaxLength { get; set; } = 150;
} }
} }

4
modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Clients/ClientGrantTypeConsts.cs

@ -2,6 +2,6 @@
{ {
public class ClientGrantTypeConsts public class ClientGrantTypeConsts
{ {
public const int GrantTypeMaxLength = 250; public static int GrantTypeMaxLength { get; set; } = 250;
} }
} }

19
modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Devices/DeviceFlowCodesConsts.cs

@ -2,11 +2,18 @@
{ {
public class DeviceFlowCodesConsts public class DeviceFlowCodesConsts
{ {
public const int DeviceCodeMaxLength = 200; public static int DeviceCodeMaxLength { get; set; } = 200;
public const int UserCodeMaxLength = 200;
public const int SubjectIdMaxLength = 200; public static int UserCodeMaxLength { get; set; } = 200;
public const int ClientIdMaxLength = 200;
public const int DataMaxLength = 50000; public static int SubjectIdMaxLength { get; set; } = 200;
public static int DataMaxLengthValue { get; set; } = DataMaxLength;
public static int SessionIdMaxLength { get; set; } = 100;
public static int DescriptionMaxLength { get; set; } = 200;
public static int ClientIdMaxLength { get; set; } = 200;
public static int DataMaxLength { get; set; } = 50000;
} }
} }

22
modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Grants/PersistedGrantConsts.cs

@ -6,30 +6,40 @@
/// Default value: 200 /// Default value: 200
/// </summary> /// </summary>
public static int KeyMaxLength { get; set; } = 200; public static int KeyMaxLength { get; set; } = 200;
/// <summary> /// <summary>
/// Default value: 50 /// Default value: 50
/// </summary> /// </summary>
public static int TypeMaxLength { get; set; } = 50; public static int TypeMaxLength { get; set; } = 50;
/// <summary> /// <summary>
/// Default value: 200 /// Default value: 200
/// </summary> /// </summary>
public static int SubjectIdMaxLength { get; set; } = 200; public static int SubjectIdMaxLength { get; set; } = 200;
/// <summary>
/// Default value: 100
/// </summary>
public static int SessionIdMaxLength { get; set; } = 100;
/// <summary> /// <summary>
/// Default value: 200 /// Default value: 200
/// </summary> /// </summary>
public static int ClientIdMaxLength { get; set; } = 200; public static int ClientIdMaxLength { get; set; } = 200;
/// <summary>
/// Default value: 200
/// </summary>
public static int DescriptionMaxLength { get; set; } = 200;
/// <summary> /// <summary>
/// Default value: 50000 /// Default value: 50000
/// </summary> /// </summary>
public static int DataMaxLength { get; set; } = 50000; public static int DataMaxLength { get; set; } = 50000;
/// <summary> /// <summary>
/// Default value: 50000 /// Default value: 50000
/// </summary> /// </summary>
public static int DataMaxLengthValue { get; set; } = 50000; public static int DataMaxLengthValue { get; set; } = 50000;
} }
} }

8
modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceConsts.cs

@ -6,15 +6,15 @@
/// Default value: 200 /// Default value: 200
/// </summary> /// </summary>
public static int NameMaxLength { get; set; } = 200; public static int NameMaxLength { get; set; } = 200;
/// <summary> /// <summary>
/// Default value: 200 /// Default value: 200
/// </summary> /// </summary>
public static int DisplayNameMaxLength { get; set; } = 200; public static int DisplayNameMaxLength { get; set; } = 200;
/// <summary> /// <summary>
/// Default value: 200 /// Default value: 1000
/// </summary> /// </summary>
public static int DescriptionMaxLength { get; set; } = 1000; public static int DescriptionMaxLength { get; set; } = 1000;
} }
} }

6
modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/IdentityResources/IdentityResourcePropertyConsts.cs

@ -2,8 +2,8 @@
{ {
public class IdentityResourcePropertyConsts public class IdentityResourcePropertyConsts
{ {
public const int KeyMaxLength = 250; public static int KeyMaxLength { get; set; } = 250;
public const int ValueMaxLength = 2000;
public static int ValueMaxLengthValue { get; set; } = ValueMaxLength; public static int ValueMaxLength { get; set; } = 2000;
} }
} }

9
modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/ObjectExtending/IdentityServerModuleExtensionConfiguration.cs

@ -23,6 +23,15 @@ namespace Volo.Abp.ObjectExtending
); );
} }
public IdentityServerModuleExtensionConfiguration ConfigureApiScope(
Action<EntityExtensionConfiguration> configureAction)
{
return this.ConfigureEntity(
IdentityServerModuleExtensionConsts.EntityNames.ApiScope,
configureAction
);
}
public IdentityServerModuleExtensionConfiguration ConfigureIdentityResource( public IdentityServerModuleExtensionConfiguration ConfigureIdentityResource(
Action<EntityExtensionConfiguration> configureAction) Action<EntityExtensionConfiguration> configureAction)
{ {

4
modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/ObjectExtending/IdentityServerModuleExtensionConsts.cs

@ -11,6 +11,8 @@
public const string IdentityResource = "IdentityResource"; public const string IdentityResource = "IdentityResource";
public const string ApiResource = "ApiResource"; public const string ApiResource = "ApiResource";
public const string ApiScope = "ApiScope";
} }
} }
} }

1
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerDomainModule.cs

@ -8,6 +8,7 @@ using Volo.Abp.BackgroundWorkers;
using Volo.Abp.Caching; using Volo.Abp.Caching;
using Volo.Abp.Domain.Entities.Events.Distributed; using Volo.Abp.Domain.Entities.Events.Distributed;
using Volo.Abp.Identity; using Volo.Abp.Identity;
using Volo.Abp.IdentityServer.ApiResources;
using Volo.Abp.IdentityServer.ApiScopes; using Volo.Abp.IdentityServer.ApiScopes;
using Volo.Abp.IdentityServer.Clients; using Volo.Abp.IdentityServer.Clients;
using Volo.Abp.IdentityServer.Devices; using Volo.Abp.IdentityServer.Devices;

25
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResource.cs

@ -4,6 +4,7 @@ using System.Linq;
using IdentityServer4; using IdentityServer4;
using JetBrains.Annotations; using JetBrains.Annotations;
using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.IdentityServer.ApiResources;
namespace Volo.Abp.IdentityServer.ApiScopes namespace Volo.Abp.IdentityServer.ApiScopes
{ {
@ -28,7 +29,7 @@ namespace Volo.Abp.IdentityServer.ApiScopes
public virtual List<ApiResourceClaim> UserClaims { get; protected set; } public virtual List<ApiResourceClaim> UserClaims { get; protected set; }
public virtual Dictionary<string, string> Properties { get; protected set; } public virtual List<ApiResourceProperty> Properties { get; protected set; }
protected ApiResource() protected ApiResource()
{ {
@ -51,7 +52,7 @@ namespace Volo.Abp.IdentityServer.ApiScopes
Secrets = new List<ApiResourceSecret>(); Secrets = new List<ApiResourceSecret>();
Scopes = new List<ApiResourceScope>(); Scopes = new List<ApiResourceScope>();
UserClaims = new List<ApiResourceClaim>(); UserClaims = new List<ApiResourceClaim>();
Properties = new Dictionary<string, string>(); Properties = new List<ApiResourceProperty>();
Scopes.Add(new ApiResourceScope(id, name)); Scopes.Add(new ApiResourceScope(id, name));
} }
@ -121,5 +122,25 @@ namespace Volo.Abp.IdentityServer.ApiScopes
{ {
return Scopes.FirstOrDefault(r => r.Scope == scope); return Scopes.FirstOrDefault(r => r.Scope == scope);
} }
public virtual void AddProperty([NotNull] string key, string value)
{
Properties.Add(new ApiResourceProperty(Id, key, value));
}
public virtual void RemoveAllProperties()
{
Properties.Clear();
}
public virtual void RemoveProperty(string key)
{
Properties.RemoveAll(r => r.Key == key);
}
public virtual ApiResourceProperty FindProperty(string key)
{
return Properties.FirstOrDefault(r => r.Key == key);
}
} }
} }

39
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResourceProperty.cs

@ -0,0 +1,39 @@
using System;
using JetBrains.Annotations;
using Volo.Abp.Domain.Entities;
namespace Volo.Abp.IdentityServer.ApiResources
{
public class ApiResourceProperty : Entity
{
public virtual Guid ApiResourceId { get; protected set; }
public virtual string Key { get; set; }
public virtual string Value { get; set; }
protected ApiResourceProperty()
{
}
public virtual bool Equals(Guid aiResourceId, [NotNull] string key, string value)
{
return ApiResourceId == aiResourceId && Key == key && Value == value;
}
protected internal ApiResourceProperty(Guid aiResourceId, [NotNull] string key, [NotNull] string value)
{
Check.NotNull(key, nameof(key));
ApiResourceId = aiResourceId;
Key = key;
Value = value;
}
public override object[] GetKeys()
{
return new object[] { ApiResourceId, Key };
}
}
}

5
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/IApiResourceRepository.cs

@ -35,11 +35,6 @@ namespace Volo.Abp.IdentityServer.ApiScopes
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
); );
Task<List<ApiResource>> GetListAsync(
bool includeDetails = false,
CancellationToken cancellationToken = default
);
Task<bool> CheckNameExistAsync( Task<bool> CheckNameExistAsync(
string name, string name,
Guid? expectedId = null, Guid? expectedId = null,

4
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiScopes/ApiScope.cs

@ -59,7 +59,7 @@ namespace Volo.Abp.IdentityServer.ApiScopes
public virtual void AddUserClaim([NotNull] string type) public virtual void AddUserClaim([NotNull] string type)
{ {
UserClaims.Add(new ApiScopeClaim(Id, Name, type)); UserClaims.Add(new ApiScopeClaim(Id, type));
} }
public virtual void RemoveAllUserClaims() public virtual void RemoveAllUserClaims()
@ -74,7 +74,7 @@ namespace Volo.Abp.IdentityServer.ApiScopes
public virtual ApiScopeClaim FindClaim(string type) public virtual ApiScopeClaim FindClaim(string type)
{ {
return UserClaims.FirstOrDefault(r => r.Name == Name && r.Type == type); return UserClaims.FirstOrDefault(r => r.Type == type);
} }
public virtual void AddProperty([NotNull] string key, string value) public virtual void AddProperty([NotNull] string key, string value)

14
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiScopes/ApiScopeClaim.cs

@ -7,31 +7,25 @@ namespace Volo.Abp.IdentityServer.ApiScopes
{ {
public Guid ApiScopeId { get; protected set; } public Guid ApiScopeId { get; protected set; }
[NotNull]
public string Name { get; protected set; }
protected ApiScopeClaim() protected ApiScopeClaim()
{ {
} }
public virtual bool Equals(Guid apiScopeId, [NotNull] string name, [NotNull] string type) public virtual bool Equals(Guid apiScopeId, [NotNull] string type)
{ {
return ApiScopeId == apiScopeId && Name == name && Type == type; return ApiScopeId == apiScopeId && Type == type;
} }
protected internal ApiScopeClaim(Guid apiScopeId, [NotNull] string name, [NotNull] string type) protected internal ApiScopeClaim(Guid apiScopeId, [NotNull] string type)
: base(type) : base(type)
{ {
Check.NotNull(name, nameof(name));
ApiScopeId = apiScopeId; ApiScopeId = apiScopeId;
Name = name;
} }
public override object[] GetKeys() public override object[] GetKeys()
{ {
return new object[] { ApiScopeId, Name, Type }; return new object[] { ApiScopeId, Type };
} }
} }
} }

4
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceProperty.cs

@ -17,9 +17,9 @@ namespace Volo.Abp.IdentityServer.IdentityResources
} }
public virtual bool Equals(Guid identityResourceId, [NotNull] string key) public virtual bool Equals(Guid identityResourceId, [NotNull] string key, string value)
{ {
return IdentityResourceId == identityResourceId && Key == key; return IdentityResourceId == identityResourceId && Key == key && Value == value;
} }
protected internal IdentityResourceProperty(Guid identityResourceId, [NotNull] string key, [NotNull] string value) protected internal IdentityResourceProperty(Guid identityResourceId, [NotNull] string key, [NotNull] string value)

117
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityServerAutoMapperProfile.cs

@ -1,6 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Security.Claims; using System.Security.Claims;
using AutoMapper; using AutoMapper;
using Volo.Abp.IdentityServer.ApiResources;
using Volo.Abp.IdentityServer.ApiScopes; using Volo.Abp.IdentityServer.ApiScopes;
using Volo.Abp.IdentityServer.Clients; using Volo.Abp.IdentityServer.Clients;
using Volo.Abp.IdentityServer.Devices; using Volo.Abp.IdentityServer.Devices;
@ -11,58 +12,32 @@ namespace Volo.Abp.IdentityServer
{ {
public class IdentityServerAutoMapperProfile : Profile public class IdentityServerAutoMapperProfile : Profile
{ {
/// <summary>
/// TODO: Reverse maps will not used probably. Remove those will not used
/// </summary>
public IdentityServerAutoMapperProfile() public IdentityServerAutoMapperProfile()
{ {
//TODO: Reverse maps will not used probably. Remove those will not used
CreateMap<ClientCorsOrigin, string>()
.ConstructUsing(src => src.Origin)
.ReverseMap()
.ForMember(dest => dest.Origin, opt => opt.MapFrom(src => src));
CreateMap<ApiResource, IdentityServer4.Models.ApiResource>()
.ForMember(dest => dest.ApiSecrets, opt => opt.MapFrom(src => src.Secrets));
CreateMap<ApiResourceSecret, IdentityServer4.Models.Secret>();
//TODO: Why PersistedGrant mapping is in this profile?
CreateMap<PersistedGrant, IdentityServer4.Models.PersistedGrant>().ReverseMap();
CreateMap<IdentityResource, IdentityServer4.Models.IdentityResource>()
.ConstructUsing(src => new IdentityServer4.Models.IdentityResource());
CreateMap<IdentityResourceClaim, string>()
.ConstructUsing(x => x.Type)
.ReverseMap()
.ForMember(dest => dest.Type, opt => opt.MapFrom(src => src));
CreateMap<IdentityResourceProperty, KeyValuePair<string, string>>()
.ReverseMap();
CreateMap<UserClaim, string>() CreateMap<UserClaim, string>()
.ConstructUsing(src => src.Type) .ConstructUsing(src => src.Type)
.ReverseMap() .ReverseMap()
.ForMember(dest => dest.Type, opt => opt.MapFrom(src => src)); .ForMember(dest => dest.Type, opt => opt.MapFrom(src => src));
CreateMap<ApiResourceScope, string>() CreateClientMap();
.ConstructUsing(x => x.Scope) CreateApiResourceMap();
.ReverseMap() CreateApiScopeMap();
.ForMember(dest => dest.Scope, opt => opt.MapFrom(src => src)); CreateIdentityResourceMap();
CreatePersistedGrantMap();
CreateMap<ApiScopeProperty, KeyValuePair<string, string>>() CreateDeviceFlowCodesMap();
.ReverseMap(); }
CreateMap<ApiScopeClaim, string>() private void CreateClientMap()
.ConstructUsing(x => x.Type) {
CreateMap<ClientCorsOrigin, string>()
.ConstructUsing(src => src.Origin)
.ReverseMap() .ReverseMap()
.ForMember(dest => dest.Type, opt => opt.MapFrom(src => src)); .ForMember(dest => dest.Origin, opt => opt.MapFrom(src => src));
CreateMap<ApiScope, IdentityServer4.Models.ApiScope>(MemberList.Destination)
.ConstructUsing(src => new IdentityServer4.Models.ApiScope())
.ReverseMap();
CreateMap<ClientProperty, KeyValuePair<string, string>>() CreateMap<ClientProperty, KeyValuePair<string, string>>()
.ReverseMap(); .ReverseMap();
CreateMap<Client, IdentityServer4.Models.Client>() CreateMap<Client, IdentityServer4.Models.Client>()
@ -115,10 +90,64 @@ namespace Volo.Abp.IdentityServer
CreateMap<ApiResource, ApiResourceEto>(); CreateMap<ApiResource, ApiResourceEto>();
CreateMap<Client, ClientEto>(); CreateMap<Client, ClientEto>();
CreateMap<DeviceFlowCodes, DeviceFlowCodesEto>(); }
CreateMap<PersistedGrant, PersistedGrantEto>();
private void CreateApiResourceMap()
{
CreateMap<ApiResource, IdentityServer4.Models.ApiResource>()
.ForMember(dest => dest.ApiSecrets, opt => opt.MapFrom(src => src.Secrets));
CreateMap<ApiResourceSecret, IdentityServer4.Models.Secret>();
CreateMap<ApiResourceScope, string>()
.ConstructUsing(x => x.Scope)
.ReverseMap()
.ForMember(dest => dest.Scope, opt => opt.MapFrom(src => src));
CreateMap<ApiResource, ApiResourceEto>();
}
private void CreateApiScopeMap()
{
CreateMap<ApiScopeProperty, KeyValuePair<string, string>>()
.ReverseMap();
CreateMap<ApiScopeClaim, string>()
.ConstructUsing(x => x.Type)
.ReverseMap()
.ForMember(dest => dest.Type, opt => opt.MapFrom(src => src));
CreateMap<ApiScope, IdentityServer4.Models.ApiScope>(MemberList.Destination)
.ConstructUsing(src => new IdentityServer4.Models.ApiScope())
.ReverseMap();
}
private void CreateIdentityResourceMap()
{
CreateMap<IdentityResource, IdentityServer4.Models.IdentityResource>()
.ConstructUsing(src => new IdentityServer4.Models.IdentityResource());
CreateMap<IdentityResourceClaim, string>()
.ConstructUsing(x => x.Type)
.ReverseMap()
.ForMember(dest => dest.Type, opt => opt.MapFrom(src => src));
CreateMap<IdentityResourceProperty, KeyValuePair<string, string>>()
.ReverseMap();
CreateMap<IdentityResource, IdentityResourceEto>(); CreateMap<IdentityResource, IdentityResourceEto>();
}
private void CreatePersistedGrantMap()
{
//TODO: Why PersistedGrant mapping is in this profile?
CreateMap<PersistedGrant, IdentityServer4.Models.PersistedGrant>().ReverseMap();
CreateMap<PersistedGrant, PersistedGrantEto>();
}
private void CreateDeviceFlowCodesMap()
{
CreateMap<DeviceFlowCodes, DeviceFlowCodesEto>();
} }
} }
} }

3
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/AbpIdentityServerEfCoreQueryableExtensions.cs

@ -18,7 +18,8 @@ namespace Volo.Abp.IdentityServer
return queryable return queryable
.Include(x => x.Secrets) .Include(x => x.Secrets)
.Include(x => x.UserClaims) .Include(x => x.UserClaims)
.Include(x => x.Scopes); .Include(x => x.Scopes)
.Include(x => x.Properties);
} }
public static IQueryable<ApiScope> IncludeDetails(this IQueryable<ApiScope> queryable, bool include = true) public static IQueryable<ApiScope> IncludeDetails(this IQueryable<ApiScope> queryable, bool include = true)

9
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/ApiResources/ApiResourceRepository.cs

@ -67,15 +67,6 @@ namespace Volo.Abp.IdentityServer.ApiScopes
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public virtual async Task<List<ApiResource>> GetListAsync(
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await DbSet
.IncludeDetails(includeDetails)
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<bool> CheckNameExistAsync(string name, Guid? expectedId = null, CancellationToken cancellationToken = default) public virtual async Task<bool> CheckNameExistAsync(string name, Guid? expectedId = null, CancellationToken cancellationToken = default)
{ {
return await DbSet.AnyAsync(ar => ar.Id != expectedId && ar.Name == name, cancellationToken: cancellationToken); return await DbSet.AnyAsync(ar => ar.Id != expectedId && ar.Name == name, cancellationToken: cancellationToken);

1
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/AbpIdentityServerEntityFrameworkCoreModule.cs

@ -33,6 +33,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
options.AddRepository<Client, ClientRepository>(); options.AddRepository<Client, ClientRepository>();
options.AddRepository<ApiResource, ApiResourceRepository>(); options.AddRepository<ApiResource, ApiResourceRepository>();
options.AddRepository<ApiScope, ApiScopeRepository>();
options.AddRepository<IdentityResource, IdentityResourceRepository>(); options.AddRepository<IdentityResource, IdentityResourceRepository>();
options.AddRepository<PersistedGrant, PersistentGrantRepository>(); options.AddRepository<PersistedGrant, PersistentGrantRepository>();
options.AddRepository<DeviceFlowCodes, DeviceFlowCodesRepository>(); options.AddRepository<DeviceFlowCodes, DeviceFlowCodesRepository>();

1
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IIdentityServerDbContext.cs

@ -34,7 +34,6 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
#endregion #endregion
#region IdentityResource #region IdentityResource
DbSet<IdentityResource> IdentityResources { get; set; } DbSet<IdentityResource> IdentityResources { get; set; }

1
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContext.cs

@ -34,7 +34,6 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
#endregion #endregion
#region IdentityResource #region IdentityResource
public DbSet<IdentityResource> IdentityResources { get; set; } public DbSet<IdentityResource> IdentityResources { get; set; }

111
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs

@ -1,10 +1,8 @@
using System; using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.Modeling; using Volo.Abp.EntityFrameworkCore.Modeling;
using Volo.Abp.EntityFrameworkCore.ValueComparers; using Volo.Abp.IdentityServer.ApiResources;
using Volo.Abp.EntityFrameworkCore.ValueConverters;
using Volo.Abp.IdentityServer.ApiScopes; using Volo.Abp.IdentityServer.ApiScopes;
using Volo.Abp.IdentityServer.Clients; using Volo.Abp.IdentityServer.Clients;
using Volo.Abp.IdentityServer.Devices; using Volo.Abp.IdentityServer.Devices;
@ -188,31 +186,6 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
b.Property(x => x.Value).HasMaxLength(ClientPropertyConsts.ValueMaxLength).IsRequired(); b.Property(x => x.Value).HasMaxLength(ClientPropertyConsts.ValueMaxLength).IsRequired();
}); });
builder.Entity<PersistedGrant>(b =>
{
b.ToTable(options.TablePrefix + "PersistedGrants", options.Schema);
b.ConfigureByConvention();
b.Property(x => x.Key).HasMaxLength(PersistedGrantConsts.KeyMaxLength).ValueGeneratedNever();
b.Property(x => x.Type).HasMaxLength(PersistedGrantConsts.TypeMaxLength).IsRequired();
b.Property(x => x.SubjectId).HasMaxLength(PersistedGrantConsts.SubjectIdMaxLength);
b.Property(x => x.ClientId).HasMaxLength(PersistedGrantConsts.ClientIdMaxLength).IsRequired();
b.Property(x => x.CreationTime).IsRequired();
if (IsDatabaseProvider(builder, options, EfCoreDatabaseProvider.MySql))
{
PersistedGrantConsts.DataMaxLengthValue = 10000; //TODO: MySQL accepts 20.000. We can consider to change in v3.0.
}
b.Property(x => x.Data).HasMaxLength(PersistedGrantConsts.DataMaxLengthValue).IsRequired();
b.HasKey(x => x.Key); //TODO: What about Id!!!
b.HasIndex(x => new {x.SubjectId, x.ClientId, x.Type});
b.HasIndex(x => x.Expiration);
});
#endregion #endregion
#region IdentityResource #region IdentityResource
@ -255,9 +228,9 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
b.Property(x => x.Key).HasMaxLength(IdentityResourcePropertyConsts.KeyMaxLength).IsRequired(); b.Property(x => x.Key).HasMaxLength(IdentityResourcePropertyConsts.KeyMaxLength).IsRequired();
if (IsDatabaseProvider(builder, options, EfCoreDatabaseProvider.MySql, EfCoreDatabaseProvider.Oracle)) if (IsDatabaseProvider(builder, options, EfCoreDatabaseProvider.MySql, EfCoreDatabaseProvider.Oracle))
{ {
IdentityResourcePropertyConsts.ValueMaxLengthValue = 300; IdentityResourcePropertyConsts.ValueMaxLength = 300;
} }
b.Property(x => x.Value).HasMaxLength(IdentityResourcePropertyConsts.ValueMaxLengthValue).IsRequired(); b.Property(x => x.Value).HasMaxLength(IdentityResourcePropertyConsts.ValueMaxLength).IsRequired();
}); });
#endregion #endregion
@ -270,16 +243,16 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
b.ConfigureByConvention(); b.ConfigureByConvention();
b.HasIndex(x => x.Name).IsUnique();
b.Property(x => x.Name).HasMaxLength(ApiResourceConsts.NameMaxLength).IsRequired(); b.Property(x => x.Name).HasMaxLength(ApiResourceConsts.NameMaxLength).IsRequired();
b.Property(x => x.DisplayName).HasMaxLength(ApiResourceConsts.DisplayNameMaxLength); b.Property(x => x.DisplayName).HasMaxLength(ApiResourceConsts.DisplayNameMaxLength);
b.Property(x => x.Description).HasMaxLength(ApiResourceConsts.DescriptionMaxLength); b.Property(x => x.Description).HasMaxLength(ApiResourceConsts.DescriptionMaxLength);
b.Property(x => x.Properties)
.HasConversion(new AbpJsonValueConverter<Dictionary<string, string>>())
.Metadata.SetValueComparer(new AbpDictionaryValueComparer<string, string>());
b.HasMany(x => x.Secrets).WithOne().HasForeignKey(x => x.ApiResourceId).IsRequired(); b.HasMany(x => x.Secrets).WithOne().HasForeignKey(x => x.ApiResourceId).IsRequired();
b.HasMany(x => x.Scopes).WithOne().HasForeignKey(x => x.ApiResourceId).IsRequired(); b.HasMany(x => x.Scopes).WithOne().HasForeignKey(x => x.ApiResourceId).IsRequired();
b.HasMany(x => x.UserClaims).WithOne().HasForeignKey(x => x.ApiResourceId).IsRequired(); b.HasMany(x => x.UserClaims).WithOne().HasForeignKey(x => x.ApiResourceId).IsRequired();
b.HasMany(x => x.Properties).WithOne().HasForeignKey(x => x.ApiResourceId).IsRequired();
}); });
builder.Entity<ApiResourceSecret>(b => builder.Entity<ApiResourceSecret>(b =>
@ -291,14 +264,14 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
b.HasKey(x => new {x.ApiResourceId, x.Type, x.Value}); b.HasKey(x => new {x.ApiResourceId, x.Type, x.Value});
b.Property(x => x.Type).HasMaxLength(ApiResourceSecretConsts.TypeMaxLength).IsRequired(); b.Property(x => x.Type).HasMaxLength(ApiResourceSecretConsts.TypeMaxLength).IsRequired();
b.Property(x => x.Description).HasMaxLength(ApiResourceSecretConsts.DescriptionMaxLength);
if (IsDatabaseProvider(builder, options, EfCoreDatabaseProvider.MySql, EfCoreDatabaseProvider.Oracle)) if (IsDatabaseProvider(builder, options, EfCoreDatabaseProvider.MySql, EfCoreDatabaseProvider.Oracle))
{ {
ApiResourceSecretConsts.ValueMaxLengthValue = 300; ApiResourceSecretConsts.ValueMaxLengthValue = 300;
} }
b.Property(x => x.Value).HasMaxLength(ApiResourceSecretConsts.ValueMaxLengthValue).IsRequired(); b.Property(x => x.Value).HasMaxLength(ApiResourceSecretConsts.ValueMaxLengthValue).IsRequired();
b.Property(x => x.Description).HasMaxLength(ApiResourceSecretConsts.DescriptionMaxLength);
}); });
builder.Entity<ApiResourceClaim>(b => builder.Entity<ApiResourceClaim>(b =>
@ -323,6 +296,22 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
b.Property(x => x.Scope).HasMaxLength(ApiResourceScopeConsts.ScopeMaxLength).IsRequired(); b.Property(x => x.Scope).HasMaxLength(ApiResourceScopeConsts.ScopeMaxLength).IsRequired();
}); });
builder.Entity<ApiResourceProperty>(b =>
{
b.ToTable(options.TablePrefix + "ApiResourceProperties", options.Schema);
b.ConfigureByConvention();
b.HasKey(x => new {x.ApiResourceId, x.Key});
b.Property(x => x.Key).HasMaxLength(ApiResourcePropertyConsts.KeyMaxLength).IsRequired();
if (IsDatabaseProvider(builder, options, EfCoreDatabaseProvider.MySql, EfCoreDatabaseProvider.Oracle))
{
ApiResourcePropertyConsts.ValueMaxLength = 300;
}
b.Property(x => x.Value).HasMaxLength(ApiResourcePropertyConsts.ValueMaxLength).IsRequired();
});
#endregion #endregion
#region ApiScope #region ApiScope
@ -340,9 +329,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
b.HasIndex(x => x.Name).IsUnique(); b.HasIndex(x => x.Name).IsUnique();
b.HasMany(x => x.UserClaims).WithOne().HasForeignKey(x => x.ApiScopeId).IsRequired(); b.HasMany(x => x.UserClaims).WithOne().HasForeignKey(x => x.ApiScopeId).IsRequired();
b.HasMany(x => x.Properties).WithOne().HasForeignKey(x => x.ApiScopeId).IsRequired();
//TODO: Identity Server does not configure the relationship of Properties
//b.HasMany(x => x.Properties).WithOne().HasForeignKey(x => x.ApiScopeId).IsRequired();
}); });
builder.Entity<ApiScopeClaim>(b => builder.Entity<ApiScopeClaim>(b =>
@ -351,10 +338,9 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
b.ConfigureByConvention(); b.ConfigureByConvention();
b.HasKey(x => new {x.ApiScopeId, x.Name, x.Type}); b.HasKey(x => new {x.ApiScopeId, x.Type});
b.Property(x => x.Type).HasMaxLength(UserClaimConsts.TypeMaxLength).IsRequired(); b.Property(x => x.Type).HasMaxLength(UserClaimConsts.TypeMaxLength).IsRequired();
b.Property(x => x.Name).HasMaxLength(ApiScopeClaimConsts.NameMaxLength).IsRequired();
}); });
builder.Entity<ApiScopeProperty>(b => builder.Entity<ApiScopeProperty>(b =>
@ -368,9 +354,41 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
b.Property(x => x.Key).HasMaxLength(ApiScopePropertyConsts.KeyMaxLength).IsRequired(); b.Property(x => x.Key).HasMaxLength(ApiScopePropertyConsts.KeyMaxLength).IsRequired();
if (IsDatabaseProvider(builder, options, EfCoreDatabaseProvider.MySql, EfCoreDatabaseProvider.Oracle)) if (IsDatabaseProvider(builder, options, EfCoreDatabaseProvider.MySql, EfCoreDatabaseProvider.Oracle))
{ {
ApiScopePropertyConsts.ValueMaxLengthValue = 300; ApiScopePropertyConsts.ValueMaxLength = 300;
} }
b.Property(x => x.Value).HasMaxLength(ApiScopePropertyConsts.ValueMaxLengthValue).IsRequired(); b.Property(x => x.Value).HasMaxLength(ApiScopePropertyConsts.ValueMaxLength).IsRequired();
});
#endregion
#region PersistedGrant
builder.Entity<PersistedGrant>(b =>
{
b.ToTable(options.TablePrefix + "PersistedGrants", options.Schema);
b.ConfigureByConvention();
b.Property(x => x.Key).HasMaxLength(PersistedGrantConsts.KeyMaxLength).ValueGeneratedNever();
b.Property(x => x.Type).HasMaxLength(PersistedGrantConsts.TypeMaxLength).IsRequired();
b.Property(x => x.SubjectId).HasMaxLength(PersistedGrantConsts.SubjectIdMaxLength);
b.Property(x => x.SessionId).HasMaxLength(PersistedGrantConsts.SessionIdMaxLength);
b.Property(x => x.ClientId).HasMaxLength(PersistedGrantConsts.ClientIdMaxLength).IsRequired();
b.Property(x => x.Description).HasMaxLength(PersistedGrantConsts.DescriptionMaxLength);
b.Property(x => x.CreationTime).IsRequired();
if (IsDatabaseProvider(builder, options, EfCoreDatabaseProvider.MySql))
{
PersistedGrantConsts.DataMaxLengthValue = 10000; //TODO: MySQL accepts 20.000. We can consider to change in v3.0.
}
b.Property(x => x.Data).HasMaxLength(PersistedGrantConsts.DataMaxLengthValue).IsRequired();
b.HasKey(x => x.Key); //TODO: What about Id!!!
b.HasIndex(x => new {x.SubjectId, x.ClientId, x.Type});
b.HasIndex(x => new {x.SubjectId, x.SessionId, x.Type});
b.HasIndex(x => x.Expiration);
}); });
#endregion #endregion
@ -386,16 +404,19 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
b.Property(x => x.DeviceCode).HasMaxLength(DeviceFlowCodesConsts.DeviceCodeMaxLength).IsRequired(); b.Property(x => x.DeviceCode).HasMaxLength(DeviceFlowCodesConsts.DeviceCodeMaxLength).IsRequired();
b.Property(x => x.UserCode).HasMaxLength(DeviceFlowCodesConsts.UserCodeMaxLength).IsRequired(); b.Property(x => x.UserCode).HasMaxLength(DeviceFlowCodesConsts.UserCodeMaxLength).IsRequired();
b.Property(x => x.SubjectId).HasMaxLength(DeviceFlowCodesConsts.SubjectIdMaxLength); b.Property(x => x.SubjectId).HasMaxLength(DeviceFlowCodesConsts.SubjectIdMaxLength);
b.Property(x => x.SessionId).HasMaxLength(DeviceFlowCodesConsts.SessionIdMaxLength);
b.Property(x => x.ClientId).HasMaxLength(DeviceFlowCodesConsts.ClientIdMaxLength).IsRequired(); b.Property(x => x.ClientId).HasMaxLength(DeviceFlowCodesConsts.ClientIdMaxLength).IsRequired();
b.Property(x => x.Description).HasMaxLength(DeviceFlowCodesConsts.DescriptionMaxLength);
b.Property(x => x.CreationTime).IsRequired();
b.Property(x => x.Expiration).IsRequired(); b.Property(x => x.Expiration).IsRequired();
if (IsDatabaseProvider(builder, options, EfCoreDatabaseProvider.MySql)) if (IsDatabaseProvider(builder, options, EfCoreDatabaseProvider.MySql))
{ {
DeviceFlowCodesConsts.DataMaxLengthValue = 10000; //TODO: MySQL accepts 20.000. We can consider to change in v3.0. DeviceFlowCodesConsts.DataMaxLength = 10000; //TODO: MySQL accepts 20.000. We can consider to change in v3.0.
} }
b.Property(x => x.Data).HasMaxLength(DeviceFlowCodesConsts.DataMaxLengthValue).IsRequired(); b.Property(x => x.Data).HasMaxLength(DeviceFlowCodesConsts.DataMaxLength).IsRequired();
b.HasIndex(x => new {x.UserCode}).IsUnique(); b.HasIndex(x => new {x.UserCode});
b.HasIndex(x => x.DeviceCode).IsUnique(); b.HasIndex(x => x.DeviceCode).IsUnique();
b.HasIndex(x => x.Expiration); b.HasIndex(x => x.Expiration);
}); });

2
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs

@ -182,7 +182,7 @@ namespace MyCompanyName.MyProjectName.IdentityServer
AccessTokenLifetime = 31536000, //365 days AccessTokenLifetime = 31536000, //365 days
AuthorizationCodeLifetime = 300, AuthorizationCodeLifetime = 300,
IdentityTokenLifetime = 300, IdentityTokenLifetime = 300,
RequireConsent = false, RequireConsent = true,
RequirePkce = false, RequirePkce = false,
FrontChannelLogoutUri = frontChannelLogoutUri FrontChannelLogoutUri = frontChannelLogoutUri
}, },

Loading…
Cancel
Save