|
|
|
@ -4,10 +4,12 @@ using System.Net.Http; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; |
|
|
|
using Volo.Abp.Caching; |
|
|
|
using Volo.Abp.Http.Client; |
|
|
|
using Volo.Abp.Http.Client.Authentication; |
|
|
|
using Volo.Abp.Security.Claims; |
|
|
|
using Volo.Abp.Users; |
|
|
|
|
|
|
|
namespace Volo.Abp.AspNetCore.Mvc.Client; |
|
|
|
|
|
|
|
@ -18,17 +20,23 @@ public class RemoteDynamicClaimsPrincipalContributorCache : RemoteDynamicClaimsP |
|
|
|
protected IDistributedCache<AbpDynamicClaimCacheItem> Cache { get; } |
|
|
|
protected IHttpClientFactory HttpClientFactory { get; } |
|
|
|
protected IRemoteServiceHttpClientAuthenticator HttpClientAuthenticator { get; } |
|
|
|
protected IDistributedCache<ApplicationConfigurationDto> ApplicationConfigurationDtoCache { get; } |
|
|
|
protected ICurrentUser CurrentUser { get; } |
|
|
|
|
|
|
|
public RemoteDynamicClaimsPrincipalContributorCache( |
|
|
|
IDistributedCache<AbpDynamicClaimCacheItem> cache, |
|
|
|
IHttpClientFactory httpClientFactory, |
|
|
|
IOptions<AbpClaimsPrincipalFactoryOptions> abpClaimsPrincipalFactoryOptions, |
|
|
|
IRemoteServiceHttpClientAuthenticator httpClientAuthenticator) |
|
|
|
IRemoteServiceHttpClientAuthenticator httpClientAuthenticator, |
|
|
|
IDistributedCache<ApplicationConfigurationDto> applicationConfigurationDtoCache, |
|
|
|
ICurrentUser currentUser) |
|
|
|
: base(abpClaimsPrincipalFactoryOptions) |
|
|
|
{ |
|
|
|
Cache = cache; |
|
|
|
HttpClientFactory = httpClientFactory; |
|
|
|
HttpClientAuthenticator = httpClientAuthenticator; |
|
|
|
ApplicationConfigurationDtoCache = applicationConfigurationDtoCache; |
|
|
|
CurrentUser = currentUser; |
|
|
|
} |
|
|
|
|
|
|
|
protected async override Task<AbpDynamicClaimCacheItem?> GetCacheAsync(Guid userId, Guid? tenantId = null) |
|
|
|
@ -49,6 +57,7 @@ public class RemoteDynamicClaimsPrincipalContributorCache : RemoteDynamicClaimsP |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
Logger.LogWarning(e, $"Failed to refresh remote claims for user: {userId}"); |
|
|
|
await ApplicationConfigurationDtoCache.RemoveAsync(MvcCachedApplicationConfigurationClientHelper.CreateCacheKey(CurrentUser)); |
|
|
|
throw; |
|
|
|
} |
|
|
|
} |
|
|
|
|