From a13a90e14c7ba661f7de277c06cdede1dbea0055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Wed, 31 Jan 2018 15:35:52 +0300 Subject: [PATCH] Set Id of new PersistentGrant entities. --- .../Abp/IdentityServer/Clients/ClientAutoMapperProfile.cs | 1 + .../Volo/Abp/IdentityServer/Grants/PersistedGrantStore.cs | 6 +++++- .../Volo/Abp/IdentityServer/Jwt/JwtTokenMiddleware.cs | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientAutoMapperProfile.cs b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientAutoMapperProfile.cs index 4da5ff2093..3d3393e7b8 100644 --- a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientAutoMapperProfile.cs +++ b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientAutoMapperProfile.cs @@ -23,6 +23,7 @@ namespace Volo.Abp.IdentityServer.Clients CreateMap() .ForMember(dest => dest.ApiSecrets, opt => opt.MapFrom(src => src.Secrets)); + //TODO: Why PersistedGrant mapping is in this profile? CreateMap().ReverseMap(); CreateMap(); diff --git a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Grants/PersistedGrantStore.cs b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Grants/PersistedGrantStore.cs index 31ab551053..0d40241ee5 100644 --- a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Grants/PersistedGrantStore.cs +++ b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Grants/PersistedGrantStore.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Threading.Tasks; using IdentityServer4.Stores; using Volo.Abp.DependencyInjection; +using Volo.Abp.Guids; using Volo.Abp.ObjectMapping; namespace Volo.Abp.IdentityServer.Grants @@ -11,11 +12,13 @@ namespace Volo.Abp.IdentityServer.Grants { private readonly IPersistentGrantRepository _persistentGrantRepository; private readonly IObjectMapper _objectMapper; + private readonly IGuidGenerator _guidGenerator; - public PersistedGrantStore(IPersistentGrantRepository persistentGrantRepository, IObjectMapper objectMapper) + public PersistedGrantStore(IPersistentGrantRepository persistentGrantRepository, IObjectMapper objectMapper, IGuidGenerator guidGenerator) { _persistentGrantRepository = persistentGrantRepository; _objectMapper = objectMapper; + _guidGenerator = guidGenerator; } public virtual async Task StoreAsync(IdentityServer4.Models.PersistedGrant grant) @@ -24,6 +27,7 @@ namespace Volo.Abp.IdentityServer.Grants var existing = await _persistentGrantRepository.FindByKeyAsync(grant.Key); if (existing == null) { + entity.Id = _guidGenerator.Create(); await _persistentGrantRepository.InsertAsync(entity); } else diff --git a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Jwt/JwtTokenMiddleware.cs b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Jwt/JwtTokenMiddleware.cs index 8dd90d2d22..57ca9cc4c2 100644 --- a/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Jwt/JwtTokenMiddleware.cs +++ b/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Jwt/JwtTokenMiddleware.cs @@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Builder; namespace Volo.Abp.IdentityServer.Jwt { - //TODO: Can we move this to another package..? + //TODO: Should we move this to another package..? public static class JwtTokenMiddleware {