add 补充缺失代码

This commit is contained in:
2024-01-15 13:37:38 +08:00
parent 415b985bb3
commit 8285e9e7da

View File

@@ -0,0 +1,29 @@
using Kurisu.AspNetCore.Startup;
namespace Dlhis.User.Packs;
public class OAuth2HttpClientPack : BaseAppPack
{
public override bool IsBeforeUseRouting { get; }
public override void ConfigureServices(IServiceCollection services)
{
services.AddHttpClient("oauth2", (sp, httpClient) =>
{
if (sp.GetService<IWebHostEnvironment>().IsProduction())
{
httpClient.DefaultRequestHeaders.Add("X-Requested-Internal", "internal");
}
})
.ConfigurePrimaryHttpMessageHandler(() =>
{
var handler = new HttpClientHandler
{
ClientCertificateOptions = ClientCertificateOption.Manual,
ServerCertificateCustomValidationCallback = (_, _, _, _) => true
};
return handler;
});
}
}