Browse Source

Update entities & fix unit tests.

pull/4578/head
maliming 6 years ago
parent
commit
85b775184c
  1. 4
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiScopeConsts.cs
  2. 6
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Devices/DeviceFlowCodesEto.cs
  3. 37
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AllowedSigningAlgorithmsConverter.cs
  4. 48
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResource.cs
  5. 38
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResourceScope.cs
  6. 20
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResourceSecret.cs
  7. 30
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScope.cs
  8. 14
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScopeClaim.cs
  9. 39
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScopeProperty.cs
  10. 9
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/Client.cs
  11. 6
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Devices/DeviceFlowCodes.cs
  12. 12
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Grants/PersistedGrant.cs
  13. 32
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityResource.cs
  14. 8
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceClaim.cs
  15. 39
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceProperty.cs
  16. 42
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityServerAutoMapperProfile.cs
  17. 1
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ResourceStore.cs
  18. 15
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/AbpIdentityServerEfCoreQueryableExtensions.cs
  19. 8
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/ApiResources/ApiResourceRepository.cs
  20. 4
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/ApiResources/ApiScopeRepository.cs
  21. 6
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IIdentityServerDbContext.cs
  22. 6
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContext.cs
  23. 85
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs
  24. 3
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/Grants/PersistedGrantRepository.cs
  25. 2
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoApiResourceRepository.cs
  26. 11
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoPersistedGrantRepository.cs
  27. 10
      modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/Clients/IdentityResourceStore_Tests.cs
  28. 7
      modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs
  29. 5
      modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs
  30. 2
      modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo/Abp/IdentityServer/PersistentGrantRepository_Tests.cs

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

@ -3,7 +3,5 @@
public class ApiScopeConsts
{
public const int NameMaxLength = 200;
public const int DisplayNameMaxLength = 200;
public const int DescriptionMaxLength = 1000;
}
}
}

6
modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Devices/DeviceFlowCodesEto.cs

@ -13,10 +13,14 @@ namespace Volo.Abp.IdentityServer.Devices
public string SubjectId { get; set; }
public string SessionId { get; set; }
public string ClientId { get; set; }
public string Description { get; set; }
public DateTime? Expiration { get; set; }
public string Data { get; set; }
}
}
}

37
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AllowedSigningAlgorithmsConverter.cs

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using AutoMapper;
namespace Volo.Abp.IdentityServer
{
public class AllowedSigningAlgorithmsConverter :
IValueConverter<ICollection<string>, string>,
IValueConverter<string, ICollection<string>>
{
public static AllowedSigningAlgorithmsConverter Converter = new AllowedSigningAlgorithmsConverter();
public string Convert(ICollection<string> sourceMember, ResolutionContext context)
{
if (sourceMember == null || !sourceMember.Any())
{
return null;
}
return sourceMember.Aggregate((x, y) => $"{x},{y}");
}
public ICollection<string> Convert(string sourceMember, ResolutionContext context)
{
var list = new HashSet<string>();
if (!String.IsNullOrWhiteSpace(sourceMember))
{
sourceMember = sourceMember.Trim();
foreach (var item in sourceMember.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Distinct())
{
list.Add(item);
}
}
return list;
}
}
}

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

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using IdentityServer4;
@ -18,9 +18,13 @@ namespace Volo.Abp.IdentityServer.ApiResources
public virtual bool Enabled { get; set; }
public virtual List<ApiSecret> Secrets { get; protected set; }
public virtual string AllowedAccessTokenSigningAlgorithms { get; set; }
public virtual List<ApiScope> Scopes { get; protected set; }
public virtual bool ShowInDiscoveryDocument { get; set; } = true;
public virtual List<ApiResourceSecret> Secrets { get; protected set; }
public virtual List<ApiResourceScope> Scopes { get; protected set; }
public virtual List<ApiResourceClaim> UserClaims { get; protected set; }
@ -44,21 +48,21 @@ namespace Volo.Abp.IdentityServer.ApiResources
Enabled = true;
Secrets = new List<ApiSecret>();
Scopes = new List<ApiScope>();
Secrets = new List<ApiResourceSecret>();
Scopes = new List<ApiResourceScope>();
UserClaims = new List<ApiResourceClaim>();
Properties = new Dictionary<string, string>();
Scopes.Add(new ApiScope(id, name, displayName, description));
Scopes.Add(new ApiResourceScope(id, name));
}
public virtual void AddSecret(
[NotNull] string value,
[NotNull] string value,
DateTime? expiration = null,
string type = IdentityServerConstants.SecretTypes.SharedSecret,
string description = null)
{
Secrets.Add(new ApiSecret(Id, value, expiration, type, description));
Secrets.Add(new ApiResourceSecret(Id, value, expiration, type, description));
}
public virtual void RemoveSecret([NotNull] string value, string type = IdentityServerConstants.SecretTypes.SharedSecret)
@ -66,22 +70,16 @@ namespace Volo.Abp.IdentityServer.ApiResources
Secrets.RemoveAll(s => s.Value == value && s.Type == type);
}
public virtual ApiSecret FindSecret([NotNull] string value, string type = IdentityServerConstants.SecretTypes.SharedSecret)
public virtual ApiResourceSecret FindSecret([NotNull] string value, string type = IdentityServerConstants.SecretTypes.SharedSecret)
{
return Secrets.FirstOrDefault(s => s.Type == type && s.Value == value);
}
public virtual ApiScope AddScope(
[NotNull] string name,
string displayName = null,
string description = null,
bool required = false,
bool emphasize = false,
bool showInDiscoveryDocument = true)
public virtual ApiResourceScope AddScope([NotNull] string scope)
{
var scope = new ApiScope(Id, name, displayName, description, required, emphasize, showInDiscoveryDocument);
Scopes.Add(scope);
return scope;
var apiResourceScope = new ApiResourceScope(Id, scope);
Scopes.Add(apiResourceScope);
return apiResourceScope;
}
public virtual void AddUserClaim([NotNull] string type)
@ -111,21 +109,17 @@ namespace Volo.Abp.IdentityServer.ApiResources
public virtual void RemoveAllScopes()
{
foreach (var scope in Scopes)
{
scope.RemoveAllUserClaims();
}
Scopes.Clear();
}
public virtual void RemoveScope(string name)
public virtual void RemoveScope(string scope)
{
Scopes.RemoveAll(r => r.Name == name);
Scopes.RemoveAll(r => r.Scope == scope);
}
public virtual ApiScope FindScope(string name)
public virtual ApiResourceScope FindScope(string scope)
{
return Scopes.FirstOrDefault(r => r.Name == name);
return Scopes.FirstOrDefault(r => r.Scope == scope);
}
}
}

38
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResourceScope.cs

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

20
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiSecret.cs → modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResourceSecret.cs

@ -4,11 +4,11 @@ using JetBrains.Annotations;
namespace Volo.Abp.IdentityServer.ApiResources
{
public class ApiSecret : Secret
public class ApiResourceSecret : Secret
{
public virtual Guid ApiResourceId { get; protected set; }
protected ApiSecret()
protected ApiResourceSecret()
{
}
@ -18,16 +18,16 @@ namespace Volo.Abp.IdentityServer.ApiResources
return ApiResourceId == apiResourceId && Value == value && Type == type;
}
protected internal ApiSecret(
protected internal ApiResourceSecret(
Guid apiResourceId,
[NotNull] string value,
DateTime? expiration = null,
string type = IdentityServerConstants.SecretTypes.SharedSecret,
[NotNull] string value,
DateTime? expiration = null,
string type = IdentityServerConstants.SecretTypes.SharedSecret,
string description = null
) : base(
value,
expiration,
type,
value,
expiration,
type,
description)
{
ApiResourceId = apiResourceId;
@ -38,4 +38,4 @@ namespace Volo.Abp.IdentityServer.ApiResources
return new object[] { ApiResourceId, Type, Value };
}
}
}
}

30
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScope.cs

@ -1,14 +1,14 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Entities.Auditing;
namespace Volo.Abp.IdentityServer.ApiResources
{
public class ApiScope : Entity
public class ApiScope : FullAuditedAggregateRoot<Guid>
{
public virtual Guid ApiResourceId { get; protected set; }
public virtual bool Enabled { get; set; }
[NotNull]
public virtual string Name { get; protected set; }
@ -25,44 +25,39 @@ namespace Volo.Abp.IdentityServer.ApiResources
public virtual List<ApiScopeClaim> UserClaims { get; protected set; }
public virtual Dictionary<string, string> Properties { get; protected set; }
public virtual List<ApiScopeProperty> Properties { get; protected set; }
protected ApiScope()
{
}
public virtual bool Equals(Guid apiResourceId, [NotNull] string name)
{
return ApiResourceId == apiResourceId && Name == name;
}
protected internal ApiScope(
Guid apiResourceId,
[NotNull] string name,
string displayName = null,
string description = null,
bool required = false,
bool emphasize = false,
bool showInDiscoveryDocument = true)
bool showInDiscoveryDocument = true,
bool enabled = true)
{
Check.NotNull(name, nameof(name));
ApiResourceId = apiResourceId;
Name = name;
DisplayName = displayName ?? name;
Description = description;
Required = required;
Emphasize = emphasize;
ShowInDiscoveryDocument = showInDiscoveryDocument;
Enabled = enabled;
UserClaims = new List<ApiScopeClaim>();
Properties = new Dictionary<string, string>();
Properties = new List<ApiScopeProperty>();
}
public virtual void AddUserClaim([NotNull] string type)
{
UserClaims.Add(new ApiScopeClaim(ApiResourceId, Name, type));
UserClaims.Add(new ApiScopeClaim(Id, Name, type));
}
public virtual void RemoveAllUserClaims()
@ -79,10 +74,5 @@ namespace Volo.Abp.IdentityServer.ApiResources
{
return UserClaims.FirstOrDefault(r => r.Name == Name && r.Type == type);
}
public override object[] GetKeys()
{
return new object[] { ApiResourceId, Name };
}
}
}

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

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

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

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

9
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/Client.cs

@ -36,6 +36,8 @@ namespace Volo.Abp.IdentityServer.Clients
public virtual bool AllowPlainTextPkce { get; set; }
public virtual bool RequireRequestObject { get; set; }
public virtual bool AllowAccessTokensViaBrowser { get; set; }
public virtual string FrontChannelLogoutUri { get; set; }
@ -50,6 +52,8 @@ namespace Volo.Abp.IdentityServer.Clients
public virtual int IdentityTokenLifetime { get; set; }
public virtual string AllowedIdentityTokenSigningAlgorithms { get; set; }
public virtual int AccessTokenLifetime { get; set; }
public virtual int AuthorizationCodeLifetime { get; set; }
@ -118,8 +122,9 @@ namespace Volo.Abp.IdentityServer.Clients
ProtocolType = IdentityServerConstants.ProtocolTypes.OpenIdConnect;
RequireClientSecret = true;
RequireConsent = true;
RequireConsent = false;
AllowRememberConsent = true;
RequirePkce = true;
FrontChannelLogoutSessionRequired = true;
BackChannelLogoutSessionRequired = true;
IdentityTokenLifetime = 300;
@ -319,4 +324,4 @@ namespace Volo.Abp.IdentityServer.Clients
return IdentityProviderRestrictions.FirstOrDefault(r => r.Provider == provider);
}
}
}
}

6
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Devices/DeviceFlowCodes.cs

@ -11,8 +11,12 @@ namespace Volo.Abp.IdentityServer.Devices
public virtual string SubjectId { get; set; }
public virtual string SessionId { get; set; }
public virtual string ClientId { get; set; }
public virtual string Description { get; set; }
public virtual DateTime? Expiration { get; set; }
public virtual string Data { get; set; }
@ -28,4 +32,4 @@ namespace Volo.Abp.IdentityServer.Devices
}
}
}
}

12
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Grants/PersistedGrant.cs

@ -1,4 +1,4 @@
using System;
using System;
using Volo.Abp.Domain.Entities;
namespace Volo.Abp.IdentityServer.Grants
@ -11,17 +11,23 @@ namespace Volo.Abp.IdentityServer.Grants
public virtual string SubjectId { get; set; }
public virtual string SessionId { get; set; }
public virtual string ClientId { get; set; }
public virtual string Description { get; set; }
public virtual DateTime CreationTime { get; set; }
public virtual DateTime? Expiration { get; set; }
public virtual DateTime? ConsumedTime { get; set; }
public virtual string Data { get; set; }
protected PersistedGrant()
{
}
public PersistedGrant(Guid id)
@ -29,4 +35,4 @@ namespace Volo.Abp.IdentityServer.Grants
Id = id;
}
}
}
}

32
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityResource.cs

@ -22,9 +22,9 @@ namespace Volo.Abp.IdentityServer.IdentityResources
public virtual bool ShowInDiscoveryDocument { get; set; }
public virtual List<IdentityClaim> UserClaims { get; set; }
public virtual List<IdentityResourceClaim> UserClaims { get; set; }
public virtual Dictionary<string, string> Properties { get; set; }
public virtual List<IdentityResourceProperty> Properties { get; set; }
protected IdentityResource()
{
@ -32,13 +32,13 @@ namespace Volo.Abp.IdentityServer.IdentityResources
}
public IdentityResource(
Guid id,
[NotNull] string name,
string displayName = null,
string description = null,
bool enabled = true,
bool required = false,
bool emphasize = false,
Guid id,
[NotNull] string name,
string displayName = null,
string description = null,
bool enabled = true,
bool required = false,
bool emphasize = false,
bool showInDiscoveryDocument = true)
{
Check.NotNull(name, nameof(name));
@ -51,9 +51,9 @@ namespace Volo.Abp.IdentityServer.IdentityResources
Required = required;
Emphasize = emphasize;
ShowInDiscoveryDocument = showInDiscoveryDocument;
UserClaims = new List<IdentityClaim>();
Properties = new Dictionary<string, string>();
UserClaims = new List<IdentityResourceClaim>();
Properties = new List<IdentityResourceProperty>();
}
public IdentityResource(Guid id, IdentityServer4.Models.IdentityResource resource)
@ -66,13 +66,13 @@ namespace Volo.Abp.IdentityServer.IdentityResources
Required = resource.Required;
Emphasize = resource.Emphasize;
ShowInDiscoveryDocument = resource.ShowInDiscoveryDocument;
UserClaims = resource.UserClaims.Select(claimType => new IdentityClaim(id, claimType)).ToList();
Properties = resource.Properties.ToDictionary(x => x.Key, x => x.Value);
UserClaims = resource.UserClaims.Select(claimType => new IdentityResourceClaim(id, claimType)).ToList();
Properties = resource.Properties.Select(x => new IdentityResourceProperty(Id, x.Key, x.Value)).ToList();
}
public virtual void AddUserClaim([NotNull] string type)
{
UserClaims.Add(new IdentityClaim(Id, type));
UserClaims.Add(new IdentityResourceClaim(Id, type));
}
public virtual void RemoveAllUserClaims()
@ -85,7 +85,7 @@ namespace Volo.Abp.IdentityServer.IdentityResources
UserClaims.RemoveAll(c => c.Type == type);
}
public virtual IdentityClaim FindUserClaim(string type)
public virtual IdentityResourceClaim FindUserClaim(string type)
{
return UserClaims.FirstOrDefault(c => c.Type == type);
}

8
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityClaim.cs → modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceClaim.cs

@ -3,11 +3,11 @@ using JetBrains.Annotations;
namespace Volo.Abp.IdentityServer.IdentityResources
{
public class IdentityClaim : UserClaim
public class IdentityResourceClaim : UserClaim
{
public virtual Guid IdentityResourceId { get; set; }
protected IdentityClaim()
protected IdentityResourceClaim()
{
}
@ -17,7 +17,7 @@ namespace Volo.Abp.IdentityServer.IdentityResources
return IdentityResourceId == identityResourceId && Type == type;
}
protected internal IdentityClaim(Guid identityResourceId, [NotNull] string type)
protected internal IdentityResourceClaim(Guid identityResourceId, [NotNull] string type)
: base(type)
{
IdentityResourceId = identityResourceId;
@ -28,4 +28,4 @@ namespace Volo.Abp.IdentityServer.IdentityResources
return new object[] { IdentityResourceId, Type };
}
}
}
}

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

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

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

@ -15,8 +15,6 @@ namespace Volo.Abp.IdentityServer
{
//TODO: Reverse maps will not used probably. Remove those will not used
CreateMap<Client, IdentityServer4.Models.Client>();
CreateMap<ClientCorsOrigin, string>()
.ConstructUsing(src => src.Origin)
.ReverseMap()
@ -25,26 +23,53 @@ namespace Volo.Abp.IdentityServer
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>();
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>()
.ConstructUsing(src => src.Type)
.ReverseMap()
.ForMember(dest => dest.Type, opt => opt.MapFrom(src => src));
CreateMap<ApiSecret, IdentityServer4.Models.Secret>();
CreateMap<ApiResourceScope, string>()
.ConstructUsing(x => x.Scope)
.ReverseMap()
.ForMember(dest => dest.Scope, opt => opt.MapFrom(src => src));
CreateMap<ApiScope, IdentityServer4.Models.ApiScope>();
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();
CreateMap<ClientProperty, KeyValuePair<string, string>>()
.ReverseMap();
CreateMap<Client, IdentityServer4.Models.Client>()
.ForMember(dest => dest.ProtocolType, opt => opt.Condition(srs => srs != null))
.ReverseMap();
.ForMember(x => x.AllowedIdentityTokenSigningAlgorithms, opts => opts.ConvertUsing(AllowedSigningAlgorithmsConverter.Converter, x => x.AllowedIdentityTokenSigningAlgorithms))
.ReverseMap()
.ForMember(x => x.AllowedIdentityTokenSigningAlgorithms, opts => opts.ConvertUsing(AllowedSigningAlgorithmsConverter.Converter, x => x.AllowedIdentityTokenSigningAlgorithms));
CreateMap<ClientCorsOrigin, string>()
.ConstructUsing(src => src.Origin)
@ -60,6 +85,10 @@ namespace Volo.Abp.IdentityServer
.ConstructUsing(src => new Claim(src.Type, src.Value))
.ReverseMap();
CreateMap<ClientClaim, IdentityServer4.Models.ClientClaim>(MemberList.None)
.ConstructUsing(src => new IdentityServer4.Models.ClientClaim(src.Type, src.Value, ClaimValueTypes.String))
.ReverseMap();
CreateMap<ClientScope, string>()
.ConstructUsing(src => src.Scope)
.ReverseMap()
@ -89,6 +118,7 @@ namespace Volo.Abp.IdentityServer
CreateMap<DeviceFlowCodes, DeviceFlowCodesEto>();
CreateMap<PersistedGrant, PersistedGrantEto>();
CreateMap<IdentityResource, IdentityResourceEto>();
}
}
}

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

@ -6,7 +6,6 @@ using IdentityServer4.Stores;
using Volo.Abp.IdentityServer.ApiResources;
using Volo.Abp.IdentityServer.IdentityResources;
using Volo.Abp.ObjectMapping;
using ApiScope = Volo.Abp.IdentityServer.ApiResources.ApiScope;
namespace Volo.Abp.IdentityServer
{

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

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

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

@ -35,7 +35,7 @@ namespace Volo.Abp.IdentityServer.ApiResources
CancellationToken cancellationToken = default)
{
var query = from api in DbSet.IncludeDetails(includeDetails)
where api.Scopes.Any(x => scopeNames.Contains(x.Name))
where api.Scopes.Any(x => scopeNames.Contains(x.Scope))
select api;
return await query.ToListAsync(GetCancellationToken(cancellationToken));
@ -74,18 +74,18 @@ namespace Volo.Abp.IdentityServer.ApiResources
public override async Task DeleteAsync(Guid id, bool autoSave = false, CancellationToken cancellationToken = default)
{
var scopeClaims = DbContext.Set<ApiScopeClaim>().Where(sc => sc.ApiResourceId == id);
var scopeClaims = DbContext.Set<ApiScopeClaim>().Where(sc => sc.ApiScopeId == id);
foreach (var scopeClaim in scopeClaims)
{
DbContext.Set<ApiScopeClaim>().Remove(scopeClaim);
}
var scopes = DbContext.Set<ApiScope>().Where(s => s.ApiResourceId == id);
var scopes = DbContext.Set<ApiResourceScope>().Where(s => s.ApiResourceId == id);
foreach (var scope in scopes)
{
DbContext.Set<ApiScope>().Remove(scope);
DbContext.Set<ApiResourceScope>().Remove(scope);
}
await base.DeleteAsync(id, autoSave, cancellationToken);

4
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/ApiResources/ApiScopeRepository.cs

@ -19,9 +19,7 @@ namespace Volo.Abp.IdentityServer.ApiResources
public async Task<List<ApiScope>> GetListByNameAsync(string[] scopeNames, bool includeDetails = false,
CancellationToken cancellationToken = default)
{
var query = from scope in DbSet.IncludeDetails(includeDetails)
where scopeNames.Contains(scope.Name)
select scope;
var query = from scope in DbSet where scopeNames.Contains(scope.Name) select scope;
return await query.ToListAsync(GetCancellationToken(cancellationToken));
}

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

@ -14,17 +14,17 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
{
DbSet<ApiResource> ApiResources { get; set; }
DbSet<ApiSecret> ApiSecrets { get; set; }
DbSet<ApiResourceSecret> ApiSecrets { get; set; }
DbSet<ApiResourceClaim> ApiResourceClaims { get; set; }
DbSet<ApiScope> ApiScopes { get; set; }
DbSet<ApiResourceScope> ApiScopes { get; set; }
DbSet<ApiScopeClaim> ApiScopeClaims { get; set; }
DbSet<IdentityResource> IdentityResources { get; set; }
DbSet<IdentityClaim> IdentityClaims { get; set; }
DbSet<IdentityResourceClaim> IdentityClaims { get; set; }
DbSet<Client> Clients { get; set; }

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

@ -14,17 +14,17 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
{
public DbSet<ApiResource> ApiResources { get; set; }
public DbSet<ApiSecret> ApiSecrets { get; set; }
public DbSet<ApiResourceSecret> ApiSecrets { get; set; }
public DbSet<ApiResourceClaim> ApiResourceClaims { get; set; }
public DbSet<ApiScope> ApiScopes { get; set; }
public DbSet<ApiResourceScope> ApiScopes { get; set; }
public DbSet<ApiScopeClaim> ApiScopeClaims { get; set; }
public DbSet<IdentityResource> IdentityResources { get; set; }
public DbSet<IdentityClaim> IdentityClaims { get; set; }
public DbSet<IdentityResourceClaim> IdentityClaims { get; set; }
public DbSet<Client> Clients { get; set; }

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

@ -81,8 +81,8 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
if (IsDatabaseProvider(builder, options, EfCoreDatabaseProvider.MySql))
{
ClientRedirectUriConsts.RedirectUriMaxLengthValue = 300;
}
}
b.Property(x => x.RedirectUri).HasMaxLength(ClientRedirectUriConsts.RedirectUriMaxLengthValue).IsRequired();
});
@ -97,8 +97,8 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
if (IsDatabaseProvider(builder, options, EfCoreDatabaseProvider.MySql))
{
ClientPostLogoutRedirectUriConsts.PostLogoutRedirectUriMaxLengthValue = 300;
}
}
b.Property(x => x.PostLogoutRedirectUri)
.HasMaxLength(ClientPostLogoutRedirectUriConsts.PostLogoutRedirectUriMaxLengthValue)
.IsRequired();
@ -129,7 +129,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
{
SecretConsts.ValueMaxLengthValue = 300;
}
b.Property(x => x.Value).HasMaxLength(SecretConsts.ValueMaxLengthValue).IsRequired();
b.Property(x => x.Description).HasMaxLength(SecretConsts.DescriptionMaxLength);
@ -195,9 +195,9 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
if (IsDatabaseProvider(builder, options, EfCoreDatabaseProvider.MySql))
{
PersistedGrantConsts.DataMaxLengthValue = 10000; //TODO: MySQL accepts 20.000. We can consider to change in v3.0.
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!!!
@ -215,16 +215,14 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
b.Property(x => x.Name).HasMaxLength(IdentityResourceConsts.NameMaxLength).IsRequired();
b.Property(x => x.DisplayName).HasMaxLength(IdentityResourceConsts.DisplayNameMaxLength);
b.Property(x => x.Description).HasMaxLength(IdentityResourceConsts.DescriptionMaxLength);
b.Property(x => x.Properties)
.HasConversion(new AbpJsonValueConverter<Dictionary<string, string>>())
.Metadata.SetValueComparer(new AbpDictionaryValueComparer<string, string>());
b.HasMany(x => x.UserClaims).WithOne().HasForeignKey(x => x.IdentityResourceId).IsRequired();
b.HasMany(x => x.Properties).WithOne().HasForeignKey(x => x.IdentityResourceId).IsRequired();
});
builder.Entity<IdentityClaim>(b =>
builder.Entity<IdentityResourceClaim>(b =>
{
b.ToTable(options.TablePrefix + "IdentityClaims", options.Schema);
b.ToTable(options.TablePrefix + "IdentityResourceClaims", options.Schema);
b.ConfigureByConvention();
@ -233,6 +231,18 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
b.Property(x => x.Type).HasMaxLength(UserClaimConsts.TypeMaxLength).IsRequired();
});
builder.Entity<IdentityResourceProperty>(b =>
{
b.ToTable(options.TablePrefix + "IdentityResourceProperties", options.Schema);
b.ConfigureByConvention();
b.HasKey(x => new {x.IdentityResourceId, x.Key});
b.Property(x => x.Key).HasMaxLength(250).IsRequired();
b.Property(x => x.Value).HasMaxLength(2000).IsRequired();
});
builder.Entity<ApiResource>(b =>
{
b.ToTable(options.TablePrefix + "ApiResources", options.Schema);
@ -251,9 +261,9 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
b.HasMany(x => x.UserClaims).WithOne().HasForeignKey(x => x.ApiResourceId).IsRequired();
});
builder.Entity<ApiSecret>(b =>
builder.Entity<ApiResourceSecret>(b =>
{
b.ToTable(options.TablePrefix + "ApiSecrets", options.Schema);
b.ToTable(options.TablePrefix + "ApiResourceSecrets", options.Schema);
b.ConfigureByConvention();
@ -265,14 +275,14 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
if (IsDatabaseProvider(builder, options, EfCoreDatabaseProvider.MySql, EfCoreDatabaseProvider.Oracle))
{
SecretConsts.ValueMaxLengthValue = 300;
}
}
b.Property(x => x.Value).HasMaxLength(SecretConsts.ValueMaxLengthValue).IsRequired();
});
builder.Entity<ApiResourceClaim>(b =>
{
b.ToTable(options.TablePrefix + "ApiClaims", options.Schema);
b.ToTable(options.TablePrefix + "ApiResourceClaims", options.Schema);
b.ConfigureByConvention();
@ -281,19 +291,33 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
b.Property(x => x.Type).HasMaxLength(UserClaimConsts.TypeMaxLength).IsRequired();
});
builder.Entity<ApiResourceScope>(b =>
{
b.ToTable(options.TablePrefix + "ApiResourceScopes", options.Schema);
b.ConfigureByConvention();
b.HasKey(x => new {x.ApiResourceId, x.Scope});
b.Property(x => x.Scope).HasMaxLength(ApiScopeConsts.NameMaxLength).IsRequired();
});
builder.Entity<ApiScope>(b =>
{
b.ToTable(options.TablePrefix + "ApiScopes", options.Schema);
b.ConfigureByConvention();
b.HasKey(x => new {x.ApiResourceId, x.Name});
b.Property(x => x.Name).HasMaxLength(200).IsRequired();
b.Property(x => x.DisplayName).HasMaxLength(200);
b.Property(x => x.Description).HasMaxLength(1000);
b.Property(x => x.Name).HasMaxLength(ApiScopeConsts.NameMaxLength).IsRequired();
b.Property(x => x.DisplayName).HasMaxLength(ApiScopeConsts.DisplayNameMaxLength);
b.Property(x => x.Description).HasMaxLength(ApiScopeConsts.DescriptionMaxLength);
b.HasIndex(x => x.Name).IsUnique();
b.HasMany(x => x.UserClaims).WithOne().HasForeignKey(x => new {x.ApiResourceId, x.Name}).IsRequired();
b.HasMany(x => x.UserClaims).WithOne().HasForeignKey(x => x.ApiScopeId).IsRequired();
//Identity Server does not configure the relationship of Properties
//b.HasMany(x => x.Properties).WithOne().HasForeignKey(x => x.ApiScopeId).IsRequired();
});
builder.Entity<ApiScopeClaim>(b =>
@ -302,12 +326,25 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
b.ConfigureByConvention();
b.HasKey(x => new {x.ApiResourceId, x.Name, x.Type});
b.HasKey(x => new {x.ApiScopeId, x.Name, x.Type});
b.Property(x => x.Type).HasMaxLength(UserClaimConsts.TypeMaxLength).IsRequired();
b.Property(x => x.Name).HasMaxLength(ApiScopeConsts.NameMaxLength).IsRequired();
});
builder.Entity<ApiScopeProperty>(b =>
{
b.ToTable(options.TablePrefix + "ApiScopeProperties", options.Schema);
b.ConfigureByConvention();
b.HasKey(x => new {x.ApiScopeId, x.Key});
b.Property(x => x.Key).HasMaxLength(250).IsRequired();
//oracle?
b.Property(x => x.Value).HasMaxLength(2000).IsRequired();
});
builder.Entity<DeviceFlowCodes>(b =>
{
b.ToTable(options.TablePrefix + "DeviceFlowCodes", options.Schema);
@ -344,4 +381,4 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
return false;
}
}
}
}

3
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/Grants/PersistedGrantRepository.cs

@ -74,10 +74,9 @@ namespace Volo.Abp.IdentityServer.Grants
string clientId,
string type)
{
//IDS TODO: add SessionId to entity
return DbSet
.WhereIf(!subjectId.IsNullOrWhiteSpace(), x => x.SubjectId == subjectId)
// .WhereIf(!sessionId.IsNullOrWhiteSpace(), x => x.SessionId == sessionId)
.WhereIf(!sessionId.IsNullOrWhiteSpace(), x => x.SessionId == sessionId)
.WhereIf(!clientId.IsNullOrWhiteSpace(), x => x.ClientId == clientId)
.WhereIf(!type.IsNullOrWhiteSpace(), x => x.Type == type);
}

2
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoApiResourceRepository.cs

@ -30,7 +30,7 @@ namespace Volo.Abp.IdentityServer.MongoDB
CancellationToken cancellationToken = default)
{
return await GetMongoQueryable()
.Where(ar => ar.Scopes.Any(x => scopeNames.Contains(x.Name)))
.Where(ar => ar.Scopes.Any(x => scopeNames.Contains(x.Scope)))
.ToListAsync(GetCancellationToken(cancellationToken));
}

11
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoPersistedGrantRepository.cs

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MongoDB.Driver;
@ -8,6 +9,7 @@ using Volo.Abp.Domain.Repositories.MongoDB;
using Volo.Abp.IdentityServer.Grants;
using Volo.Abp.MongoDB;
namespace Volo.Abp.IdentityServer.MongoDB
{
public class MongoPersistentGrantRepository : MongoDbRepository<IAbpIdentityServerMongoDbContext, PersistedGrant, Guid>, IPersistentGrantRepository
@ -85,12 +87,11 @@ namespace Volo.Abp.IdentityServer.MongoDB
string clientId,
string type)
{
//IDS TODO: add SessionId to entity
return GetMongoQueryable()
.WhereIf(!subjectId.IsNullOrWhiteSpace(), x => x.SubjectId == subjectId)
// .WhereIf(!sessionId.IsNullOrWhiteSpace(), x => x.SessionId == sessionId)
.WhereIf(!clientId.IsNullOrWhiteSpace(), x => x.ClientId == clientId)
.WhereIf(!type.IsNullOrWhiteSpace(), x => x.Type == type)
.WhereIf<PersistedGrant, IMongoQueryable<PersistedGrant>>(!subjectId.IsNullOrWhiteSpace(), x => x.SubjectId == subjectId)
.WhereIf<PersistedGrant, IMongoQueryable<PersistedGrant>>(!sessionId.IsNullOrWhiteSpace(), x => x.SessionId == sessionId)
.WhereIf<PersistedGrant, IMongoQueryable<PersistedGrant>>(!clientId.IsNullOrWhiteSpace(), x => x.ClientId == clientId)
.WhereIf<PersistedGrant, IMongoQueryable<PersistedGrant>>(!type.IsNullOrWhiteSpace(), x => x.Type == type)
.As<IMongoQueryable<PersistedGrant>>();
}
}

10
modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/Clients/IdentityResourceStore_Tests.cs

@ -19,13 +19,13 @@ namespace Volo.Abp.IdentityServer.Clients
}
[Fact]
public async Task FindApiResourceAsync_Should_Return_Null_If_Not_Found()
public async Task FindApiResourceAsync_Should_Return_Empty_If_Not_Found()
{
//Act
var resource = await _resourceStore.FindApiResourcesByNameAsync(new []{"non-existing-name"});
//Assert
resource.ShouldBeNull();
resource.ShouldBeEmpty();
}
[Fact]
@ -60,7 +60,7 @@ namespace Volo.Abp.IdentityServer.Clients
public async Task FindIdentityResourcesByScopeAsync_Should_Return_For_Given_Scopes()
{
//Act
var identityResourcesByScope = (await _resourceStore.FindApiResourcesByScopeNameAsync(new List<string>
var identityResourcesByScope = (await _resourceStore.FindIdentityResourcesByScopeNameAsync(new List<string>
{
"Test-Identity-Resource-Name-1"
})).ToArray();
@ -69,9 +69,7 @@ namespace Volo.Abp.IdentityServer.Clients
identityResourcesByScope.Length.ShouldBe(1);
identityResourcesByScope.First().DisplayName.ShouldBe("Test-Identity-Resource-DisplayName-1");
identityResourcesByScope.First().Description.ShouldBe("Test-Identity-Resource-Description-1");
//IDS TODO:
//identityResourcesByScope.First().Required.ShouldBe(true);
identityResourcesByScope.First().Required.ShouldBe(true);
}
[Fact]

7
modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs

@ -27,7 +27,7 @@ namespace Volo.Abp.IdentityServer
IClientRepository clientRepository,
IGuidGenerator guidGenerator,
IPersistentGrantRepository persistentGrantRepository,
IApiResourceRepository apiResourceRepository,
IApiResourceRepository apiResourceRepository,
IIdentityResourceRepository identityResourceRepository)
{
_clientRepository = clientRepository;
@ -51,7 +51,7 @@ namespace Volo.Abp.IdentityServer
{
ProtocolType = "TestProtocol-42"
};
client42.AddCorsOrigin("Origin1");
client42.AddScope("api1");
@ -108,7 +108,8 @@ namespace Volo.Abp.IdentityServer
};
apiResource.AddSecret("secret".Sha256());
apiResource.AddScope("Test-ApiResource-ApiScope-Name-1", "Test-ApiResource-ApiScope-DisplayName-1");
apiResource.AddScope("Test-ApiResource-ApiScope-Name-1");
apiResource.AddScope("Test-ApiResource-ApiScope-DisplayName-1");
apiResource.AddUserClaim("Test-ApiResource-Claim-Type-1");
await _apiResourceRepository.InsertAsync(apiResource);

5
modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs

@ -91,6 +91,7 @@ namespace Volo.Abp.IdentityServer
{
Key = "PersistedGrantKey1",
SubjectId = "PersistedGrantSubjectId1",
SessionId = "PersistedGrantSessionId1",
ClientId = "PersistedGrantClientId1",
Type = "PersistedGrantType1",
Data = ""
@ -147,9 +148,9 @@ namespace Volo.Abp.IdentityServer
apiResource.Description = nameof(apiResource.Description);
apiResource.DisplayName = nameof(apiResource.DisplayName);
apiResource.AddScope(nameof(ApiScope.Name));
apiResource.AddScope(nameof(ApiResourceScope.Scope));
apiResource.AddUserClaim(nameof(ApiResourceClaim.Type));
apiResource.AddSecret(nameof(ApiSecret.Value));
apiResource.AddSecret(nameof(ApiResourceSecret.Value));
await _apiResourceRepository.InsertAsync(apiResource);
await _apiResourceRepository.InsertAsync(new ApiResource(_guidGenerator.Create(), "NewApiResource2"));

2
modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo/Abp/IdentityServer/PersistentGrantRepository_Tests.cs

@ -36,7 +36,7 @@ namespace Volo.Abp.IdentityServer
[Fact]
public async Task DeleteBySubjectIdAndClientId()
{
await _persistentGrantRepository.DeleteAsync("PersistedGrantSubjectId1", "PersistedGrantClientId1");
await _persistentGrantRepository.DeleteAsync("PersistedGrantSubjectId1", "PersistedGrantSessionId1", "PersistedGrantClientId1");
var persistedGrants = await _persistentGrantRepository.GetListAsync();
persistedGrants.ShouldNotBeEmpty();

Loading…
Cancel
Save