Hi,
After the deep check, it's really a problem, only working the first time.
You can try this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using IdentityServer4.Configuration;
using IdentityServer4.Models;
using IdentityServer4.Stores;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Options;
using Volo.Abp.Caching;
using Volo.Abp.DependencyInjection;
using Volo.Abp.IdentityServer;
using Volo.Abp.IdentityServer.ApiResources;
using Volo.Abp.IdentityServer.ApiScopes;
using Volo.Abp.IdentityServer.IdentityResources;
using Volo.Abp.ObjectMapping;
using ApiResource = Volo.Abp.IdentityServer.ApiResources.ApiResource;
using ApiScope = Volo.Abp.IdentityServer.ApiScopes.ApiScope;
using IdentityResource = Volo.Abp.IdentityServer.IdentityResources.IdentityResource;
namespace Qa.Data;
[ExposeServices(typeof(ResourceStore), typeof(IResourceStore))]
public class MyResourceStore : ResourceStore
{
public MyResourceStore(IIdentityResourceRepository identityResourceRepository,
IObjectMapper<AbpIdentityServerDomainModule> objectMapper, IApiResourceRepository apiResourceRepository,
IApiScopeRepository apiScopeRepository,
IDistributedCache<IdentityServer4.Models.IdentityResource> identityResourceCache,
IDistributedCache<IdentityServer4.Models.ApiScope> apiScopeCache,
IDistributedCache<IdentityServer4.Models.ApiResource> apiResourceCache,
IDistributedCache<Resources> resourcesCache, IOptions<IdentityServerOptions> options) : base(
identityResourceRepository, objectMapper, apiResourceRepository, apiScopeRepository, identityResourceCache,
apiScopeCache, apiResourceCache, resourcesCache, options)
{
}
protected override async Task<IEnumerable<TModel>> GetCacheItemsAsync<TEntity, TModel>(
IDistributedCache<TModel> cache, IEnumerable<string> keys, Func<string[], Task<List<TEntity>>> entityFactory,
Func<List<TModel>, string, List<IEnumerable<KeyValuePair<string, TModel>>>> cacheItemsFactory,
string cacheKeyPrefix = null)
{
var result = await base.GetCacheItemsAsync(cache, keys, entityFactory, cacheItemsFactory,
cacheKeyPrefix);
if (result is IEnumerable<IdentityServer4.Models.ApiResource> apiResources)
{
return (IEnumerable<TModel>) apiResources.DistinctBy(x => x.Name);
}
return result;
}
}
Add your *.EntityFrameworkCore
module
public override void PreConfigureServices(ServiceConfigurationContext context)
{
QaEfCoreEntityExtensionMappings.Configure();
PreConfigure<IIdentityServerBuilder>(builder =>
{
builder.AddResourceStore<MyResourceStore>();
});
}
How about the error when editing the Identity Client?
Can you share the logs?
I think due to this error, the cache has not been removed.
Can you provide the full steps to reproduce? I will check it.
Hi,
If you haven't changed the method signature(method name, parameter, return type.. ) and route, then you don't need to regenerate.
However, you can run the abp generate command to re-generate client proxies.
Hi,
Yes, we cached the client, the cache item will remove when the client changed, See https://github.com/abpframework/abp/blob/dev/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityServerCacheItemInvalidator.cs#L33
However, you can set the expiration date
, try:
Configure<IdentityServerOptions>(options =>
{
options.Caching.ClientStoreExpiration = ....;
})
Hi,
We implemented this feature in 6.0(next version), so, it will come soon
Hi,
I will check it and back to you
Hi,
Can you share a project with me? shiwei.liang@volosoft.com I will check it out.