From 38e2c7212171a91ca724cd848f7b55e1081c429d Mon Sep 17 00:00:00 2001 From: maliming Date: Tue, 3 Mar 2020 08:31:28 +0800 Subject: [PATCH] Revert "Use `IHttpClientFactory` instead of manually creating a `HttpClient`" --- .../Volo.Abp.IdentityModel.csproj | 1 - .../IdentityModelAuthenticationService.cs | 19 ++++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/framework/src/Volo.Abp.IdentityModel/Volo.Abp.IdentityModel.csproj b/framework/src/Volo.Abp.IdentityModel/Volo.Abp.IdentityModel.csproj index ce26fe7bea..3e4ae78b91 100644 --- a/framework/src/Volo.Abp.IdentityModel/Volo.Abp.IdentityModel.csproj +++ b/framework/src/Volo.Abp.IdentityModel/Volo.Abp.IdentityModel.csproj @@ -16,7 +16,6 @@ - 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 6487f6ce65..ca6e41d60d 100644 --- a/framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelAuthenticationService.cs +++ b/framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelAuthenticationService.cs @@ -21,15 +21,12 @@ namespace Volo.Abp.IdentityModel public ILogger Logger { get; set; } protected AbpIdentityClientOptions ClientOptions { get; } protected ICancellationTokenProvider CancellationTokenProvider { get; } - protected IHttpClientFactory HttpClientFactory { get; } public IdentityModelAuthenticationService( IOptions options, - ICancellationTokenProvider cancellationTokenProvider, - IHttpClientFactory httpClientFactory) + ICancellationTokenProvider cancellationTokenProvider) { CancellationTokenProvider = cancellationTokenProvider; - HttpClientFactory = httpClientFactory; ClientOptions = options.Value; Logger = NullLogger.Instance; } @@ -98,7 +95,7 @@ namespace Volo.Abp.IdentityModel protected virtual async Task GetDiscoveryResponse( IdentityClientConfiguration configuration) { - using (var httpClient = HttpClientFactory.CreateClient()) + using (var httpClient = new HttpClient()) { return await httpClient.GetDiscoveryDocumentAsync(new DiscoveryDocumentRequest { @@ -112,10 +109,10 @@ namespace Volo.Abp.IdentityModel } protected virtual async Task GetTokenResponse( - DiscoveryDocumentResponse discoveryResponse, + DiscoveryDocumentResponse discoveryResponse, IdentityClientConfiguration configuration) { - using (var httpClient = HttpClientFactory.CreateClient()) + using (var httpClient = new HttpClient()) { switch (configuration.GrantType) { @@ -137,7 +134,7 @@ namespace Volo.Abp.IdentityModel protected virtual Task CreatePasswordTokenRequestAsync(DiscoveryDocumentResponse discoveryResponse, IdentityClientConfiguration configuration) { - var request = new PasswordTokenRequest + var request = new PasswordTokenRequest { Address = discoveryResponse.TokenEndpoint, Scope = configuration.Scope, @@ -152,11 +149,11 @@ namespace Volo.Abp.IdentityModel return Task.FromResult(request); } - protected virtual Task CreateClientCredentialsTokenRequestAsync( - DiscoveryDocumentResponse discoveryResponse, + protected virtual Task CreateClientCredentialsTokenRequestAsync( + DiscoveryDocumentResponse discoveryResponse, IdentityClientConfiguration configuration) { - var request = new ClientCredentialsTokenRequest + var request = new ClientCredentialsTokenRequest { Address = discoveryResponse.TokenEndpoint, Scope = configuration.Scope,