diff --git a/framework/src/Volo.Abp.IdentityModel/Volo.Abp.IdentityModel.csproj b/framework/src/Volo.Abp.IdentityModel/Volo.Abp.IdentityModel.csproj
index ce26fe7bea..6c19f18397 100644
--- a/framework/src/Volo.Abp.IdentityModel/Volo.Abp.IdentityModel.csproj
+++ b/framework/src/Volo.Abp.IdentityModel/Volo.Abp.IdentityModel.csproj
@@ -17,6 +17,7 @@
+
diff --git a/framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/AbpIdentityModelModule.cs b/framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/AbpIdentityModelModule.cs
index d0a08707b5..83660b35cf 100644
--- a/framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/AbpIdentityModelModule.cs
+++ b/framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/AbpIdentityModelModule.cs
@@ -1,11 +1,13 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity;
+using Volo.Abp.MultiTenancy;
using Volo.Abp.Threading;
namespace Volo.Abp.IdentityModel
{
[DependsOn(
- typeof(AbpThreadingModule)
+ typeof(AbpThreadingModule),
+ typeof(AbpMultiTenancyModule)
)]
public class AbpIdentityModelModule : AbpModule
{
diff --git a/framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelAuthenticationService.cs b/framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelAuthenticationService.cs
index b78a05c684..66add8892a 100644
--- a/framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelAuthenticationService.cs
+++ b/framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelAuthenticationService.cs
@@ -11,6 +11,7 @@ using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
+using Volo.Abp.MultiTenancy;
using Volo.Abp.Threading;
namespace Volo.Abp.IdentityModel
@@ -22,15 +23,18 @@ namespace Volo.Abp.IdentityModel
protected AbpIdentityClientOptions ClientOptions { get; }
protected ICancellationTokenProvider CancellationTokenProvider { get; }
protected IHttpClientFactory HttpClientFactory { get; }
+ protected ICurrentTenant CurrentTenant { get; }
public IdentityModelAuthenticationService(
IOptions options,
ICancellationTokenProvider cancellationTokenProvider,
- IHttpClientFactory httpClientFactory)
+ IHttpClientFactory httpClientFactory,
+ ICurrentTenant currentTenant)
{
ClientOptions = options.Value;
CancellationTokenProvider = cancellationTokenProvider;
HttpClientFactory = httpClientFactory;
+ CurrentTenant = currentTenant;
Logger = NullLogger.Instance;
}
@@ -125,6 +129,8 @@ namespace Volo.Abp.IdentityModel
{
using (var httpClient = HttpClientFactory.CreateClient())
{
+ AddHeaders(httpClient);
+
switch (configuration.GrantType)
{
case OidcConstants.GrantTypes.ClientCredentials:
@@ -186,5 +192,15 @@ namespace Volo.Abp.IdentityModel
return Task.CompletedTask;
}
+
+ protected virtual void AddHeaders(HttpClient client)
+ {
+ //tenantId
+ if (CurrentTenant.Id.HasValue)
+ {
+ //TODO: Use AbpAspNetCoreMultiTenancyOptions to get the key
+ client.DefaultRequestHeaders.Add(TenantResolverConsts.DefaultTenantKey, CurrentTenant.Id.Value.ToString());
+ }
+ }
}
}